Skip to content

Commit

Permalink
Add sync option for nextcloudcmd.
Browse files Browse the repository at this point in the history
Signed-off-by: Camila Ayres <hello@camilasan.com>
  • Loading branch information
camilasan committed Jun 25, 2024
1 parent acb5b81 commit f2122f4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/cmd/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ int main(int argc, char **argv)
SyncOptions syncOptions;
syncOptions.fillFromEnvironmentVariables();
syncOptions.verifyChunkSizes();
syncOptions.setIsCmd(true);
SyncEngine engine(account, options.source_dir, syncOptions, folder, &db);
engine.setIgnoreHiddenFiles(options.ignoreHiddenFiles);
engine.setNetworkLimits(options.uplimit, options.downlimit);
Expand Down
3 changes: 2 additions & 1 deletion src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,8 @@ void SyncEngine::slotDiscoveryFinished()
qCInfo(lcEngine) << "#### Post-Reconcile end #################################################### " << _stopWatch.addLapTime(QStringLiteral("Post-Reconcile Finished")) << "ms";
};

if (!_hasNoneFiles && _hasRemoveFile && ConfigFile().promptDeleteFiles()) {
const auto displayDialog = ConfigFile().promptDeleteFiles() && !_syncOptions.isCmd();
if (!_hasNoneFiles && _hasRemoveFile && displayDialog) {
qCInfo(lcEngine) << "All the files are going to be changed, asking the user";
int side = 0; // > 0 means more deleted on the server. < 0 means more deleted on the client
for (const auto &it : _syncItems) {
Expand Down
11 changes: 11 additions & 0 deletions src/libsync/syncoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ using namespace OCC;

SyncOptions::SyncOptions()
: _vfs(new VfsOff)
, _isCmd(false)
{
}

Expand Down Expand Up @@ -91,3 +92,13 @@ void SyncOptions::setPathPattern(const QString &pattern)
_fileRegex.setPatternOptions(Utility::fsCasePreserving() ? QRegularExpression::CaseInsensitiveOption : QRegularExpression::NoPatternOption);
_fileRegex.setPattern(pattern);
}

void SyncOptions::setIsCmd(const bool isCmd)
{
_isCmd = isCmd;
}

bool SyncOptions::isCmd() const
{
return _isCmd;
}
7 changes: 6 additions & 1 deletion src/libsync/syncoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class OWNCLOUDSYNC_EXPORT SyncOptions
*/
void verifyChunkSizes();


/** A regular expression to match file names
* If no pattern is provided the default is an invalid regular expression.
*/
Expand All @@ -109,6 +108,10 @@ class OWNCLOUDSYNC_EXPORT SyncOptions
*/
void setPathPattern(const QString &pattern);

/** sync had been started via nextcloudcmd command line */
[[nodiscard]] bool isCmd() const;
void setIsCmd(const bool isCmd);

private:
/**
* Only sync files that match the expression
Expand All @@ -118,6 +121,8 @@ class OWNCLOUDSYNC_EXPORT SyncOptions

qint64 _minChunkSize = chunkV2MinChunkSize;
qint64 _maxChunkSize = chunkV2MaxChunkSize;

bool _isCmd;
};

}

0 comments on commit f2122f4

Please sign in to comment.