D11745: databasesanitizer: Use flags for filtering

Stefan BrĂ¼ns noreply at phabricator.kde.org
Tue Apr 10 16:14:17 UTC 2018


bruns added inline comments.

INLINE COMMENTS

> databasesanitizer.cpp:116
>              if ((!includeIds.isEmpty() && !includeIds.contains(info.deviceId))
>                  || (!excludeIds.isEmpty() && excludeIds.contains(info.deviceId))
>                  || (urlFilter && !urlFilter->match(info.url).hasMatch())

I think this becomes a little bit clearer if you move it to the top of the map iteration and use a `continue;` to process the next item, e.g.:

  quint64 id= it.key();
  deviceId = idToDeviceId(id);  // idutils.h
  
  if (!includeIds.isEmpty() && !includeIds.contains(deviceId)) {
      continue;
  } else if (excludeIds.contains(info.deviceId)) {
      continue;
  } else if (urlFilter && !urlFilter->match(it.value()).hasMatch())
      continue;
  }
  
  checkedFiles += 1;
  FileInfo info; 
  ....
  if (info.accessible)
     accessibleCount++
  
  if ((info.accessible && !(accessFilter & IgnoreAvailable)) ||
      (!info.accessible && !(accessFilter & IgnoreUnavailable))) {
      result.append(info);
  }


`ignoredCount = map.size() - checkedFiles`
`inaccessibleCount = checkedFiles - accessibleCount`

> michaelh wrote in databasesanitizer.cpp:134
> I'm not content with this solution. Still, it's the best I could do without bloating the code too much.

for the second, return

  struct summary {
      quint64 ignored;
      quint64 accessible;
      quint64 inaccessible;
  };

> databasesanitizer.cpp:183
> +            if ((it.value().mounted && !(accessFilter & DatabaseSanitizer::IgnoreMounted))
> +                || (!it.value().mounted && !(accessFilter & DatabaseSanitizer::IgnoreUnmounted))
> +            ) {

You can omit `DatabaseSanitizer::` here

> bruns wrote in databasesanitizer.h:41
> Hm still awkward:
> 
>   IgnoreNone = 0,
>   IgnoreAvailable = 1,
>   IgnoreUnavailable = 2,
>   IgnoreMounted = IgnoreAvailable << 4,       <--  (1 << 4) == 16
>   IgnoreUnmounted = IgnoreUnavailable << 4    <--  (2 << 4) == 32

Thats probably not what you want - IgnoreUnmounted (mounted-only) implicitly includes IgnoreUnavailable, so you will exclude listing unavailable files even on mounted filesystems.

REPOSITORY
  R293 Baloo

REVISION DETAIL
  https://phabricator.kde.org/D11745

To: michaelh, #baloo, #frameworks
Cc: bruns, ngraham, smithjd, ashaposhnikov, michaelh, astippich, spoorun, alexeymin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180410/ea5cccbf/attachment.html>


More information about the Kde-frameworks-devel mailing list