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?
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.
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.
The comment is wrong, this code is sorting by size [use a different predicate function]
what's the todo? implementing "deleting the oldest"? (better put the TODO inside the method then ;)
Probably due to double encoding. Might be fixed by my suggestion of using KFileItem(UDSEntry).
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.
|
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
|