mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Csync: Plug code for csync_file_locked_or_open
This commit is contained in:
parent
b39359c929
commit
7f752c7e93
5 changed files with 26 additions and 6 deletions
|
@ -102,7 +102,8 @@ enum csync_status_codes_e {
|
|||
/* Codes for file individual status: */
|
||||
CSYNC_STATUS_INDIVIDUAL_IS_SYMLINK,
|
||||
CSYNC_STATUS_INDIVIDUAL_IGNORE_LIST,
|
||||
CSYNC_STATUS_INDIVIDUAL_IS_INVALID_CHARS
|
||||
CSYNC_STATUS_INDIVIDUAL_IS_INVALID_CHARS,
|
||||
CYSNC_STATUS_FILE_LOCKED_OR_OPEN
|
||||
};
|
||||
|
||||
typedef enum csync_status_codes_e CSYNC_STATUS;
|
||||
|
|
|
@ -223,6 +223,16 @@ static int _csync_merge_algorithm_visitor(void *obj, void *data) {
|
|||
/* file on current replica is changed or new */
|
||||
case CSYNC_INSTRUCTION_EVAL:
|
||||
case CSYNC_INSTRUCTION_NEW:
|
||||
// This operation is usually a no-op and will by default return false
|
||||
if (csync_file_locked_or_open(ctx->local.uri, cur->path)) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "[Reconciler] IGNORING file %s/%s since it is locked / open", ctx->local.uri, cur->path);
|
||||
cur->instruction = CSYNC_INSTRUCTION_ERROR;
|
||||
if (cur->error_status == CSYNC_STATUS_OK) // don't overwrite error
|
||||
cur->error_status = CYSNC_STATUS_FILE_LOCKED_OR_OPEN;
|
||||
break;
|
||||
} else {
|
||||
//CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "[Reconciler] not ignoring file %s/%s", ctx->local.uri, cur->path);
|
||||
}
|
||||
switch (other->instruction) {
|
||||
/* file on other replica is changed or new */
|
||||
case CSYNC_INSTRUCTION_NEW:
|
||||
|
|
|
@ -182,8 +182,14 @@ csync_vio_file_stat_t *csync_vio_convert_file_stat(csync_file_stat_t *st) {
|
|||
}
|
||||
|
||||
bool (*csync_file_locked_or_open_ext) (const char*) = 0; // filled in by library user
|
||||
bool csync_file_locked_or_open( const char *file) {
|
||||
if (!csync_file_locked_or_open_ext)
|
||||
bool csync_file_locked_or_open( const char *dir, const char *fname) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "csync_file_locked_or_open %p %s/%s", csync_file_locked_or_open_ext, dir, fname);
|
||||
if (!csync_file_locked_or_open_ext) {
|
||||
return false;
|
||||
return csync_file_locked_or_open_ext(file);
|
||||
}
|
||||
char *tmp_uri = NULL;
|
||||
asprintf(&tmp_uri, "%s/%s", dir, fname);
|
||||
bool ret = csync_file_locked_or_open_ext(tmp_uri);
|
||||
SAFE_FREE(tmp_uri);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,5 @@ void csync_win32_set_file_hidden( const char *file, bool hidden );
|
|||
/* Convert a csync_file_stat_t to csync_vio_file_stat_t */
|
||||
csync_vio_file_stat_t *csync_vio_convert_file_stat(csync_file_stat_t *st);
|
||||
|
||||
bool csync_file_locked_or_open( const char *file);
|
||||
|
||||
bool csync_file_locked_or_open( const char *dir, const char *fname);
|
||||
#endif /* _CSYNC_UTIL_H */
|
||||
|
|
|
@ -177,6 +177,9 @@ QString SyncEngine::csyncErrorToString(CSYNC_STATUS err)
|
|||
case CSYNC_STATUS_ABORTED:
|
||||
errStr = tr("Aborted by the user");
|
||||
break;
|
||||
case CYSNC_STATUS_FILE_LOCKED_OR_OPEN:
|
||||
errStr = "File locked"; // don't translate, internal use!
|
||||
break;
|
||||
|
||||
default:
|
||||
errStr = tr("An internal error number %1 happened.").arg( (int) err );
|
||||
|
@ -279,6 +282,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
|||
case CSYNC_STATUS_INDIVIDUAL_IS_INVALID_CHARS:
|
||||
item._errorString = tr("File contains invalid characters that can not be synced cross platform.");
|
||||
break;
|
||||
|
||||
default:
|
||||
Q_ASSERT("Non handled error-status");
|
||||
/* No error string */
|
||||
|
|
Loading…
Reference in a new issue