[Pkg-owncloud-commits] [owncloud-client] 27/69: Propagator: report error when deleting directories
Sandro Knauß
hefee-guest at moszumanska.debian.org
Fri Nov 7 19:41:08 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 7810da51a8cdd2f8bc109c823b3e4dc2010e9a81
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Wed Oct 29 12:23:48 2014 +0100
Propagator: report error when deleting directories
Will help to understand why a directory cannot be removed
Will help for #2348
---
src/mirall/propagatorjobs.cpp | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/src/mirall/propagatorjobs.cpp b/src/mirall/propagatorjobs.cpp
index f3895e0..b3ea60e 100644
--- a/src/mirall/propagatorjobs.cpp
+++ b/src/mirall/propagatorjobs.cpp
@@ -50,7 +50,8 @@
namespace Mirall {
// Code copied from Qt5's QDir::removeRecursively
-static bool removeRecursively(const QString &path)
+// (and modified to report the error)
+static bool removeRecursively(const QString &path, QString &error)
{
bool success = true;
QDirIterator di(path, QDir::AllEntries | QDir::Hidden | QDir::System | QDir::NoDotAndDotDot);
@@ -58,15 +59,28 @@ static bool removeRecursively(const QString &path)
di.next();
const QFileInfo& fi = di.fileInfo();
bool ok;
- if (fi.isDir() && !fi.isSymLink())
- ok = removeRecursively(di.filePath()); // recursive
- else
- ok = QFile::remove(di.filePath());
+ if (fi.isDir() && !fi.isSymLink()) {
+ ok = removeRecursively(di.filePath(), error); // recursive
+ } else {
+ QFile f(di.filePath());
+ ok = f.remove();
+ if (!ok) {
+ error += PropagateLocalRemove::tr("Error removing '%1': %2; ").
+ arg(QDir::toNativeSeparators(f.fileName()), f.errorString());
+ qDebug() << "Error removing " << f.fileName() << ':' << f.errorString();
+ }
+ }
if (!ok)
success = false;
}
- if (success)
+ if (success) {
success = QDir().rmdir(path);
+ if (!success) {
+ error += PropagateLocalRemove::tr("Could not remove directory '%1'; ")
+ .arg(QDir::toNativeSeparators(path));
+ qDebug() << "Error removing directory" << path;
+ }
+ }
return success;
}
@@ -83,9 +97,9 @@ void PropagateLocalRemove::start()
}
if (_item._isDirectory) {
- if (QDir(filename).exists() && !removeRecursively(filename)) {
- done(SyncFileItem::NormalError, tr("Could not remove directory %1")
- .arg(QDir::toNativeSeparators(filename)));
+ QString error;
+ if (QDir(filename).exists() && !removeRecursively(filename, error)) {
+ done(SyncFileItem::NormalError, error);
return;
}
} else {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list