This is an automatically generated e-mail. To reply, visit: http://git.reviewboard.kde.org/r/102083/

directoryusagenotifier/cleanupdirectory.h (Diff revision 4)
private:
56
    bool rm(KUrl itemToDelete);
const KUrl &

directoryusagenotifier/cleanupdirectory.cpp (Diff revision 4)
void CleanUpDirectory::setupDirectories()
50
        // The documentation sais it should be 1 or 2. But actually it only works with 0.
Which docu is wrong? I see 0, 1, and 2 being mentionned both in KIO::stat and in StatJob::setDetails.

OK actually that's for stat(), I don't see any docu for the metadata "details" used by ListJob. Where did you see one?

directoryusagenotifier/cleanupdirectory.cpp (Diff revision 4)
void CleanUpDirectory::setupDirectories()
56
        entriesJob->exec();
OUCH, nested event loops are evil, and even more so in kded. Please don't use KJob::exec here. Just let the job run.
It will autodelete itself, so no need for kill either.

directoryusagenotifier/cleanupdirectory.cpp (Diff revision 4)
void CleanUpDirectory::setupDirectories()
65
        KFileItem file(entryList.at(i), KUrl(mCurrentURL, entryList.at(i).stringValue(KIO::UDSEntry::UDS_NAME)), true);
Q_FOREACH would make this simpler and faster (no need to call .at(i) twice)

Also, there's a KFileItem constructor that takes a UDSEntry as input. This way it won't have to stat() again every file, to get its attributes and size.

directoryusagenotifier/cleanupdirectory.cpp (Diff revision 4)
void CleanUpDirectory::setupDirectories()
81
        sorted.insert(mEntriesToSort.at(i).time(KFileItem::ModificationTime) , mEntriesToSort.at(i));
It would be much faster to sort mEntriesToSort itself, rather than copying into a different container.
Just use qSort(begin, end, predicate) and write a predicate function which sorts two kfileitems the way you want them sorted.

directoryusagenotifier/cleanupdirectory.cpp (Diff revision 4)
void CleanUpDirectory::setupDirectories()
101
    // sort the entries by ModificationTime
The comment is wrong, this code is sorting by size [use a different predicate function]

directoryusagenotifier/cleanupdirectory.cpp (Diff revision 4)
void CleanUpDirectory::setupDirectories()
123
    // sort the entries by ModificationTime
... :)

directoryusagenotifier/cleanupdirectory.cpp (Diff revision 4)
void CleanUpDirectory::setupDirectories()
143
// TODO:
what's the todo? implementing "deleting the oldest"? (better put the TODO inside the method then ;)

directoryusagenotifier/cleanupdirectory.cpp (Diff revision 4)
void CleanUpDirectory::setupDirectories()
151
    // FIXME: Can not delete files with %20 in the filename
Probably due to double encoding. Might be fixed by my suggestion of using KFileItem(UDSEntry).

directoryusagenotifier/cleanupdirectory.cpp (Diff revision 4)
void CleanUpDirectory::setupDirectories()
156
        delJob->exec();
Don't use exec. Since these are always local files, I would suggest simply QFile::remove(itemToDelete.localPath());

- David


On September 21st, 2011, 7:37 p.m., Jaime Torres Amate wrote:

Review request for kdelibs.
By Jaime Torres Amate.

Updated Sept. 21, 2011, 7:37 p.m.

Description

Checks the head of a queue of directories every x minutes (default 30) to see if this directory (and children) use more space than the allowed (default 512 Mib). If so, it shows a notification allowing the user to clean the oldest files, open the file manager, or configure the daemon (time to wait for the next directory, delete automatically...).

Testing

It works as expected.
It shows the notification, and deletes the oldest files in the .thumbnail directory until the files left use less or equal space than the specified.
Bugs: 79943

Diffs

  • CMakeLists.txt (1d7c637)
  • directoryusagenotifier/CMakeLists.txt (PRE-CREATION)
  • directoryusagenotifier/COPYING (PRE-CREATION)
  • directoryusagenotifier/Messages.sh (PRE-CREATION)
  • directoryusagenotifier/README (PRE-CREATION)
  • directoryusagenotifier/cleanupdirectory.h (PRE-CREATION)
  • directoryusagenotifier/cleanupdirectory.cpp (PRE-CREATION)
  • directoryusagenotifier/directoryusagenotifier.h (PRE-CREATION)
  • directoryusagenotifier/directoryusagenotifier.cpp (PRE-CREATION)
  • directoryusagenotifier/directoryusagenotifier.desktop (PRE-CREATION)
  • directoryusagenotifier/directoryusagenotifier.kcfg (PRE-CREATION)
  • directoryusagenotifier/directoryusagenotifier.notifyrc (PRE-CREATION)
  • directoryusagenotifier/directoryusagenotifier_config.cpp (PRE-CREATION)
  • directoryusagenotifier/directoryusagenotifier_prefs_base.ui (PRE-CREATION)
  • directoryusagenotifier/module.h (PRE-CREATION)
  • directoryusagenotifier/module.cpp (PRE-CREATION)
  • directoryusagenotifier/settings.kcfgc (PRE-CREATION)
  • directoryusagenotifier/tests/CMakeLists.txt (PRE-CREATION)
  • directoryusagenotifier/tests/cleanupunittest.cpp (PRE-CREATION)

View Diff