Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/common/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ bool Utility::urlEqual(QUrl url1, QUrl url2)
return url1.matches(url2, QUrl::StripTrailingSlash | QUrl::NormalizePathSegments);
}

QString Utility::makeConflictFileName(
const QString &fn, const QDateTime &dt, const QString &user)
QString Utility::makeConflictFileName(const QString &fn, const QDateTime &dt)
{
QString conflictFileName(fn);
// Add conflict tag before the extension.
Expand All @@ -392,12 +391,6 @@ QString Utility::makeConflictFileName(
}

QString conflictMarker = QStringLiteral(" (conflicted copy ");
if (!user.isEmpty()) {
// Don't allow parens in the user name, to ensure
// we can find the beginning and end of the conflict tag.
const auto userName = sanitizeForFileName(user).replace(QLatin1Char('('), QLatin1Char('_')).replace(QLatin1Char(')'), QLatin1Char('_'));;
conflictMarker += userName + QLatin1Char(' ');
}
conflictMarker += dt.toString(QStringLiteral("yyyy-MM-dd hhmmss")) + QLatin1Char(')');

conflictFileName.insert(dotLocation, conflictMarker);
Expand Down
3 changes: 1 addition & 2 deletions src/common/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ OCSYNC_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcUtility)

/** Returns a file name based on \a fn that's suitable for a conflict.
*/
OCSYNC_EXPORT QString makeConflictFileName(
const QString &fn, const QDateTime &dt, const QString &user);
OCSYNC_EXPORT QString makeConflictFileName(const QString &fn, const QDateTime &dt);

/** Returns whether a file name indicates a conflict file
*/
Expand Down
13 changes: 4 additions & 9 deletions src/csync/csync_exclude.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ OCSYNC_EXPORT bool csync_is_windows_reserved_word(QStringView filename)
return false;
}

static CSYNC_EXCLUDE_TYPE _csync_excluded_common(QStringView path, bool excludeConflictFiles)
static CSYNC_EXCLUDE_TYPE _csync_excluded_common(QStringView path)
{
/* split up the path */
QStringView bname(path);
Expand Down Expand Up @@ -211,7 +211,7 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(QStringView path, bool excludeC
}


if (excludeConflictFiles && OCC::Utility::isConflictFile(path)) {
if (OCC::Utility::isConflictFile(path)) {
return CSYNC_FILE_EXCLUDE_CONFLICT;
}
return CSYNC_NOT_EXCLUDED;
Expand All @@ -236,11 +236,6 @@ void ExcludedFiles::addExcludeFilePath(const QString &path)
_excludeFiles.insert(path);
}

void ExcludedFiles::setExcludeConflictFiles(bool onoff)
{
_excludeConflictFiles = onoff;
}

void ExcludedFiles::addManualExclude(const QString &expr)
{
_manualExcludes.append(expr);
Expand Down Expand Up @@ -379,7 +374,7 @@ bool ExcludedFiles::isExcludedRemote(QStringView filePath, QStringView basePath,

CSYNC_EXCLUDE_TYPE ExcludedFiles::traversalPatternMatch(QStringView path, ItemType filetype) const
{
auto match = _csync_excluded_common(path, _excludeConflictFiles);
auto match = _csync_excluded_common(path);
if (match != CSYNC_NOT_EXCLUDED)
return match;
if (_allExcludes.isEmpty())
Expand Down Expand Up @@ -428,7 +423,7 @@ CSYNC_EXCLUDE_TYPE ExcludedFiles::traversalPatternMatch(QStringView path, ItemTy

CSYNC_EXCLUDE_TYPE ExcludedFiles::fullPatternMatch(QStringView p, ItemType filetype) const
{
auto match = _csync_excluded_common(p, _excludeConflictFiles);
auto match = _csync_excluded_common(p);
if (match != CSYNC_NOT_EXCLUDED)
return match;
if (_allExcludes.isEmpty())
Expand Down
9 changes: 0 additions & 9 deletions src/csync/csync_exclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ class OCSYNC_EXPORT ExcludedFiles : public QObject
*/
void addExcludeFilePath(const QString &path);

/**
* Whether conflict files shall be excluded.
*
* Defaults to true.
*/
void setExcludeConflictFiles(bool onoff);

/**
* Checks whether a file or directory should be excluded.
*
Expand Down Expand Up @@ -226,8 +219,6 @@ public Q_SLOTS:
QRegularExpression _fullRegexFile;
QRegularExpression _fullRegexDir;

bool _excludeConflictFiles = true;

/**
* Whether * and ? in patterns can match a /
*
Expand Down
10 changes: 0 additions & 10 deletions src/libsync/capabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,6 @@ QString Capabilities::invalidFilenameRegex() const
return _capabilities[QStringLiteral("dav")].toMap()[QStringLiteral("invalidFilenameRegex")].toString();
}

bool Capabilities::uploadConflictFiles() const
{
static auto envIsSet = !qEnvironmentVariableIsEmpty("OWNCLOUD_UPLOAD_CONFLICT_FILES");
static int envValue = qEnvironmentVariableIntValue("OWNCLOUD_UPLOAD_CONFLICT_FILES");
if (envIsSet)
return envValue != 0;

return _capabilities[QStringLiteral("uploadConflictFiles")].toBool();
}

bool Capabilities::versioningEnabled() const
{
return _capabilities.value(QStringLiteral("files")).toMap().value(QStringLiteral("versioning")).toBool();
Expand Down
5 changes: 0 additions & 5 deletions src/libsync/capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,6 @@ class OWNCLOUDSYNC_EXPORT Capabilities
*/
QStringList blacklistedFiles() const;

/**
* Whether conflict files should remain local (default) or should be uploaded.
*/
bool uploadConflictFiles() const;

/** Is versioning available? */
bool versioningEnabled() const;

Expand Down
30 changes: 2 additions & 28 deletions src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,18 +753,13 @@ OwncloudPropagator::DiskSpaceResult OwncloudPropagator::diskSpaceCheck() const
return DiskSpaceOk;
}

bool OwncloudPropagator::createConflict(const SyncFileItemPtr &item,
PropagatorCompositeJob *composite, QString *error)
bool OwncloudPropagator::createConflict(const SyncFileItemPtr &item, QString *error)
{
QString fn = fullLocalPath(item->_file);

QString renameError;
auto conflictModTime = FileSystem::getModTime(fn);
QString conflictUserName;
if (account()->capabilities().uploadConflictFiles())
conflictUserName = account()->davDisplayName();
QString conflictFileName = Utility::makeConflictFileName(
item->_file, Utility::qDateTimeFromTime_t(conflictModTime), conflictUserName);
QString conflictFileName = Utility::makeConflictFileName(item->_file, Utility::qDateTimeFromTime_t(conflictModTime));
QString conflictFilePath = fullLocalPath(conflictFileName);

// If the file is locked, we want to retry this sync when it
Expand Down Expand Up @@ -800,25 +795,6 @@ bool OwncloudPropagator::createConflict(const SyncFileItemPtr &item,

_journal->setConflictRecord(conflictRecord);

// Create a new upload job if the new conflict file should be uploaded
if (account()->capabilities().uploadConflictFiles()) {
if (composite && !QFileInfo(conflictFilePath).isDir()) {
SyncFileItemPtr conflictItem = SyncFileItemPtr(new SyncFileItem);
conflictItem->_file = conflictFileName;
conflictItem->_type = ItemTypeFile;
conflictItem->_direction = SyncFileItem::Up;
conflictItem->setInstruction(CSYNC_INSTRUCTION_NEW);
conflictItem->_modtime = conflictModTime;
conflictItem->_size = item->_previousSize;
Q_EMIT newItem(conflictItem);
composite->appendTask(conflictItem);
} else {
// Directories we can't process in one go. The next sync run
// will take care of uploading the conflict dir contents.
_anotherSyncNeeded = true;
}
}

return true;
}

Expand Down Expand Up @@ -907,7 +883,6 @@ void PropagatorCompositeJob::slotSubJobAbortFinished()

void PropagatorCompositeJob::appendJob(PropagatorJob *job)
{
job->setAssociatedComposite(this);
_jobsToDo.append(job);
}

Expand Down Expand Up @@ -1037,7 +1012,6 @@ PropagateDirectory::PropagateDirectory(OwncloudPropagator *propagator, const Syn
{
if (_firstJob) {
connect(_firstJob.get(), &PropagatorJob::finished, this, &PropagateDirectory::slotFirstJobFinished);
_firstJob->setAssociatedComposite(&_subJobs);
}
connect(&_subJobs, &PropagatorJob::finished, this, &PropagateDirectory::slotSubJobsFinished);
}
Expand Down
24 changes: 1 addition & 23 deletions src/libsync/owncloudpropagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,6 @@ class PropagatorJob : public QObject
*/
virtual qint64 committedDiskSpace() const { return 0; }

/** Set the associated composite job
*
* Used only from PropagatorCompositeJob itself, when a job is added
* and from PropagateDirectory to associate the subJobs with the first
* job.
*/
void setAssociatedComposite(PropagatorCompositeJob *job) { _associatedComposite = job; }

const QString path() { return _path; }

public Q_SLOTS:
Expand Down Expand Up @@ -142,16 +134,6 @@ public Q_SLOTS:
protected:
OwncloudPropagator *propagator() const;

/** If this job gets added to a composite job, this will point to the parent.
*
* For the PropagateDirectory::_firstJob it will point to
* PropagateDirectory::_subJobs.
*
* That can be useful for jobs that want to spawn follow-up jobs without
* becoming composite jobs themselves.
*/
PropagatorCompositeJob *_associatedComposite = nullptr;

private:
QString _path;
JobState _jobState;
Expand Down Expand Up @@ -496,13 +478,9 @@ class OWNCLOUDSYNC_EXPORT OwncloudPropagator : public QObject
*
* Sets up conflict records.
*
* It also creates a new upload job in composite if the item that's
* moved away is a file and conflict uploads are requested.
*
* Returns true on success, false and error on error.
*/
bool createConflict(const SyncFileItemPtr &item,
PropagatorCompositeJob *composite, QString *error);
bool createConflict(const SyncFileItemPtr &item, QString *error);

// Map original path (as in the DB) to target final path
// TODO: no public members...
Expand Down
6 changes: 3 additions & 3 deletions src/libsync/propagatedownload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void PropagateDownloadFile::start()
const bool isConflict = _item->instruction() == CSYNC_INSTRUCTION_CONFLICT && QFileInfo(fsPath).isDir();
if (isConflict) {
QString error;
if (!propagator()->createConflict(_item, _associatedComposite, &error)) {
if (!propagator()->createConflict(_item, &error)) {
done(SyncFileItem::SoftError, error);
return;
}
Expand Down Expand Up @@ -801,7 +801,7 @@ void PropagateDownloadFile::deleteExistingFolder()
}

QString error;
if (!propagator()->createConflict(_item, _associatedComposite, &error)) {
if (!propagator()->createConflict(_item, &error)) {
done(SyncFileItem::NormalError, error);
}
}
Expand Down Expand Up @@ -874,7 +874,7 @@ void PropagateDownloadFile::downloadFinished()
bool isConflict = _item->instruction() == CSYNC_INSTRUCTION_CONFLICT && (QFileInfo(fn).isDir() || !FileSystem::fileEquals(fn, _tmpFile.fileName()));
if (isConflict) {
QString error;
if (!propagator()->createConflict(_item, _associatedComposite, &error)) {
if (!propagator()->createConflict(_item, &error)) {
done(SyncFileItem::SoftError, error);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/propagatorjobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void PropagateLocalMkdir::start()
}
} else if (_item->instruction() == CSYNC_INSTRUCTION_CONFLICT) {
QString error;
if (!propagator()->createConflict(_item, _associatedComposite, &error)) {
if (!propagator()->createConflict(_item, &error)) {
done(SyncFileItem::SoftError, error);
return;
}
Expand Down
13 changes: 1 addition & 12 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,8 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item)

if (Utility::isConflictFile(item->_file))
_seenConflictFiles.insert(item->_file);
if (item->instruction() == CSYNC_INSTRUCTION_NONE) {
if (_account->capabilities().uploadConflictFiles() && Utility::isConflictFile(item->_file)) {
// For uploaded conflict files, files with no action performed on them should
// be displayed: but we mustn't overwrite the instruction if something happens
// to the file!
item->_errorString = tr("Unresolved conflict.");
item->setInstruction(CSYNC_INSTRUCTION_IGNORE);
item->_status = SyncFileItem::Conflict;
}
if (item->instruction() == CSYNC_INSTRUCTION_NONE)
return;
}

// check for blacklisting of this item.
// if the item is on blacklist, the instruction was set to ERROR
Expand Down Expand Up @@ -369,8 +360,6 @@ void SyncEngine::startSync()
// undo the filter to allow this sync to retrieve and store the correct etags.
_journal->clearEtagStorageFilter();

_excludedFiles->setExcludeConflictFiles(!_account->capabilities().uploadConflictFiles());

_lastLocalDiscoveryStyle = _localDiscoveryStyle;

bool ok;
Expand Down
Loading
Loading