Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamila San <hello@camila.codes>2020-01-03 05:32:16 +0300
committerCamila San <hello@camila.codes>2020-01-06 20:22:26 +0300
commit15af9e95194658443d26551b4110d137916e255b (patch)
tree88e73acd35227cad0af37a5c0e024f9c10b2ca7a
parentcdfe4bab8212c7189aec2fa736eec668f5b57b3f (diff)
Exclude online files from syncing.old-vd
- Add comment Signed-off-by: Camila San <hello@camila.codes>
-rw-r--r--src/csync/csync_reconcile.cpp48
-rw-r--r--src/csync/csync_update.cpp33
-rw-r--r--src/libsync/propagatedownload.cpp8
3 files changed, 64 insertions, 25 deletions
diff --git a/src/csync/csync_reconcile.cpp b/src/csync/csync_reconcile.cpp
index 3797d3478..448e22d5d 100644
--- a/src/csync/csync_reconcile.cpp
+++ b/src/csync/csync_reconcile.cpp
@@ -141,7 +141,9 @@ static void _csync_merge_algorithm_visitor(csync_file_stat_t *cur, CSYNC * ctx)
/* file has been removed on the opposite replica */
case CSYNC_INSTRUCTION_NONE:
case CSYNC_INSTRUCTION_UPDATE_METADATA:
- if (cur->virtualfile) {
+ // First sync situation, we don't have the file locally, only remote
+ if (ctx->virtualDriveEnabled &&
+ cur->virtualfile) {
/* */
break;
}
@@ -304,12 +306,15 @@ static void _csync_merge_algorithm_visitor(csync_file_stat_t *cur, CSYNC * ctx)
/* file on other replica is changed or new */
case CSYNC_INSTRUCTION_NEW:
case CSYNC_INSTRUCTION_EVAL:
+ // First time user opened the file
if (ctx->virtualDriveEnabled) {
if (cur->virtualfile) {
if (ctx->priority.files.contains(cur->path)) {
- cur->instruction = CSYNC_INSTRUCTION_NONE;
- other->instruction = CSYNC_INSTRUCTION_SYNC;
- break;
+ if (ctx->current == LOCAL_REPLICA) {
+ cur->instruction = CSYNC_INSTRUCTION_NONE;
+ other->instruction = CSYNC_INSTRUCTION_SYNC;
+ break;
+ }
}
}
}
@@ -398,15 +403,16 @@ static void _csync_merge_algorithm_visitor(csync_file_stat_t *cur, CSYNC * ctx)
other->instruction = CSYNC_INSTRUCTION_NONE;
}
+ //another case
if (ctx->virtualDriveEnabled) {
- if (cur->virtualfile) {
- if (ctx->priority.files.contains(cur->path)) {
- cur->instruction = CSYNC_INSTRUCTION_NONE;
- other->instruction = CSYNC_INSTRUCTION_SYNC;
- } else {
- cur->instruction = CSYNC_INSTRUCTION_NONE;
- other->instruction = CSYNC_INSTRUCTION_NONE;
- }
+ if (ctx->priority.files.contains(cur->path) ||
+ ctx->statedb->getSyncMode(cur->path) ==
+ OCC::SyncJournalDb::SyncMode::SYNCMODE_OFFLINE) {
+ cur->instruction = CSYNC_INSTRUCTION_SYNC;
+ other->instruction = CSYNC_INSTRUCTION_NONE;
+ } else {
+ cur->instruction = CSYNC_INSTRUCTION_NONE;
+ other->instruction = CSYNC_INSTRUCTION_NONE;
}
}
break;
@@ -422,8 +428,22 @@ static void _csync_merge_algorithm_visitor(csync_file_stat_t *cur, CSYNC * ctx)
// NEW is safer than EVAL because it will end up with
// propagation unless it's changed by something, and EVAL and
// NEW are treated equivalently during reconcile.
- if (cur->instruction == CSYNC_INSTRUCTION_EVAL)
- cur->instruction = CSYNC_INSTRUCTION_NEW;
+ if (cur->instruction == CSYNC_INSTRUCTION_EVAL) {
+ cur->instruction = CSYNC_INSTRUCTION_NEW;
+
+ //another another case
+ if (ctx->virtualDriveEnabled) {
+ if (ctx->priority.files.contains(cur->path) ||
+ ctx->statedb->getSyncMode(cur->path) ==
+ OCC::SyncJournalDb::SyncMode::SYNCMODE_OFFLINE) {
+ cur->instruction = CSYNC_INSTRUCTION_NONE;
+ other->instruction = CSYNC_INSTRUCTION_SYNC;
+ } else {
+ cur->instruction = CSYNC_INSTRUCTION_NONE;
+ other->instruction = CSYNC_INSTRUCTION_NONE;
+ }
+ }
+ }
break;
default:
break;
diff --git a/src/csync/csync_update.cpp b/src/csync/csync_update.cpp
index 754ff6065..13c72e99e 100644
--- a/src/csync/csync_update.cpp
+++ b/src/csync/csync_update.cpp
@@ -113,6 +113,10 @@ static int _csync_detect_update(CSYNC *ctx, std::unique_ptr<csync_file_stat_t> f
Q_ASSERT(fs);
OCC::SyncJournalFileRecord base;
CSYNC_EXCLUDE_TYPE excluded = CSYNC_NOT_EXCLUDED;
+ if (fs->path == "todo.md" && ctx->current == LOCAL_REPLICA) {
+ qDebug() << "";
+ }
+
if (fs->type == ItemTypeSkip) {
excluded =CSYNC_FILE_EXCLUDE_STAT_FAILED;
} else {
@@ -262,12 +266,17 @@ static int _csync_detect_update(CSYNC *ctx, std::unique_ptr<csync_file_stat_t> f
fs->instruction = CSYNC_INSTRUCTION_EVAL;
- // if (ctx->virtualDriveEnabled) {
- //if (!ctx->priority.files.contains(base._path) &&
- // ctx->statedb->getSyncMode(base._path) != OCC::SyncJournalDb::SyncMode::SYNCMODE_OFFLINE) {
- // fs->instruction = CSYNC_INSTRUCTION_IGNORE;
- //}
- // }
+ // this needs to be moved somewhere else, eval needs to be kept
+ // sync needs to happen after changing the file
+ // or this check needs to happen in reconcile
+ if (ctx->virtualDriveEnabled) {
+ if (ctx->priority.files.contains(base._path) ||
+ ctx->statedb->getSyncMode(base._path) == OCC::SyncJournalDb::SyncMode::SYNCMODE_OFFLINE) {
+ fs->instruction = CSYNC_INSTRUCTION_EVAL;
+ } else {
+ fs->instruction = CSYNC_INSTRUCTION_NONE;
+ }
+ }
goto out;
}
@@ -290,16 +299,20 @@ static int _csync_detect_update(CSYNC *ctx, std::unique_ptr<csync_file_stat_t> f
if( ctx->current == REMOTE_REPLICA ) {
fs->has_ignored_files = base._serverHasIgnoredFiles;
}
+
+ // second run or when the user opens a file
if (metadata_differ) {
/* file id or permissions has changed. Which means we need to update them in the DB. */
qCInfo(lcUpdate, "Need to update metadata for: %s", fs->path.constData());
- if (fs->virtualfile) {
- fs->instruction = CSYNC_INSTRUCTION_EVAL;
- } else {
+ if (ctx->priority.files.contains(fs->path) ||
+ ctx->statedb->getSyncMode(fs->path) == OCC::SyncJournalDb::SyncMode::SYNCMODE_OFFLINE) {
fs->instruction = CSYNC_INSTRUCTION_UPDATE_METADATA;
+ } else {
+ fs->instruction = CSYNC_INSTRUCTION_NONE;
}
} else {
- if (fs->virtualfile) {
+ if (ctx->priority.files.contains(fs->path) ||
+ ctx->statedb->getSyncMode(fs->path) == OCC::SyncJournalDb::SyncMode::SYNCMODE_OFFLINE) {
fs->instruction = CSYNC_INSTRUCTION_EVAL;
} else {
fs->instruction = CSYNC_INSTRUCTION_NONE;
diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp
index 0d397613c..1790bf2a5 100644
--- a/src/libsync/propagatedownload.cpp
+++ b/src/libsync/propagatedownload.cpp
@@ -887,7 +887,13 @@ void PropagateDownloadFile::downloadFinished()
// the discovery phase and now.
const qint64 expectedSize = _item->_previousSize;
const time_t expectedMtime = _item->_previousModtime;
- if (!FileSystem::verifyFileUnchanged(fn, expectedSize, expectedMtime)) {
+
+ SyncJournalFileRecord rec;
+ bool vf = false;
+ if (propagator()->_journal->getFileRecord(_item->_file, &rec)) {
+ vf = rec._virtualfile;
+ }
+ if (!FileSystem::verifyFileUnchanged(fn, expectedSize, expectedMtime) && !vf) {
propagator()->_anotherSyncNeeded = true;
done(SyncFileItem::SoftError, tr("File has changed since discovery"));
return;