[Pkg-owncloud-commits] [owncloud-client] 91/175: recall: move the recall code in a namespace

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Aug 8 10:36:30 UTC 2015


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 3fcce08a22379761ad3267719968bd6c7c6744e9
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Thu May 21 16:23:54 2015 +0200

    recall: move the recall code in a namespace
---
 src/libsync/propagatedownload.cpp | 66 ++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 36 deletions(-)

diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp
index 9e99e15..2416a44 100644
--- a/src/libsync/propagatedownload.cpp
+++ b/src/libsync/propagatedownload.cpp
@@ -507,27 +507,8 @@ QString makeConflictFileName(const QString &fn, const QDateTime &dt)
     return conflictFileName;
 }
 
-static QStringList parseRecallFile(const QString &fn)
-{
-    qDebug() << "parsingRecallFile: " << fn;
-
-    QStringList result;
-
-    QFile file(fn);
-    if (!file.open(QIODevice::ReadOnly)) {
-        qDebug() << file.errorString();
-        return result;
-    }
-
-    while (!file.atEnd()) {
-        QByteArray line = file.readLine();
-        line.chop(1); // remove trailing \n
-        qDebug() << "recall item: " << line;
-        result.append(line);
-    }
-    return result;
-}
 
+namespace { // Anonymous namespace for the recall feature
 static QString makeRecallFileName(const QString &fn)
 {
     QString recallFileName(fn);
@@ -544,6 +525,34 @@ static QString makeRecallFileName(const QString &fn)
     return recallFileName;
 }
 
+static void handleRecallFile(const QString &fn)
+{
+    qDebug() << "handleRecallFile: " << fn;
+
+    FileSystem::setFileHidden(fn, true);
+
+    QFile file(fn);
+    if (!file.open(QIODevice::ReadOnly)) {
+        qWarning() << "Could not open recall file" << file.errorString();
+        return;
+    }
+    QFileInfo existingFile(fn);
+    QDir thisDir = existingFile.dir();
+
+    while (!file.atEnd()) {
+        QByteArray line = file.readLine();
+        line.chop(1); // remove trailing \n
+        QString fpath = thisDir.filePath(line);
+        QString rpath = makeRecallFileName(fpath);
+
+        // if previously recalled file exists then remove it (copy will not overwrite it)
+        QFile(rpath).remove();
+        qDebug() << "Copy recall file: " << fpath << " -> " << rpath;
+        QFile::copy(fpath,rpath);
+    }
+}
+} // end namespace
+
 void PropagateDownloadFileQNAM::downloadFinished()
 {
     QString fn = _propagator->getFilePath(_item._file);
@@ -631,22 +640,7 @@ void PropagateDownloadFileQNAM::downloadFinished()
 
     // handle the special recall file
     if(_item._file == QLatin1String(".sys.admin#recall#") || _item._file.endsWith("/.sys.admin#recall#")) {
-        FileSystem::setFileHidden(fn, true);
-
-        QFileInfo existingFile(fn);
-        QDir thisDir = existingFile.dir();
-
-        QStringList recall_files = parseRecallFile(existingFile.filePath());
-
-        for (int i = 0; i < recall_files.size(); ++i) {
-            QString fpath = thisDir.filePath(recall_files.at(i));
-            QString rpath = makeRecallFileName(fpath);
-
-            // if previously recalled file exists then remove it (copy will not overwrite it)
-            QFile(rpath).remove();
-            qDebug() << "Copy recall file: " << fpath << " -> " << rpath;
-            QFile::copy(fpath,rpath);
-        }
+        handleRecallFile(fn);
     }
 }
 

-- 
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