Skip to content

Commit

Permalink
Add test for unmodified local files not getting mtimes changed upon u…
Browse files Browse the repository at this point in the history
…pload to server

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Aug 4, 2023
1 parent 0468091 commit 23f53cf
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/testsyncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "propagatorjobs.h"
#include "syncengine.h"

#include <QFile>
#include <QtTest>

using namespace OCC;
Expand Down Expand Up @@ -921,6 +922,29 @@ private slots:
QCOMPARE(QFileInfo(fakeFolder.localPath() + "foo").lastModified(), datetime);
}

// A local file should not be modified after upload to server if nothing has changed.
void testLocalFileInitialMtime()
{
constexpr auto fooFolder = "foo/";
constexpr auto barFile = "foo/bar";

FakeFolder fakeFolder{FileInfo{}};
fakeFolder.localModifier().mkdir(fooFolder);
fakeFolder.localModifier().insert(barFile);

const auto localDiskFileModifier = dynamic_cast<DiskFileModifier &>(fakeFolder.localModifier());

const auto localFile = localDiskFileModifier.find(barFile);
const auto localFileInfo = QFileInfo(localFile);
const auto expectedMtime = localFileInfo.metadataChangeTime();

QVERIFY(fakeFolder.syncOnce());
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());

const auto currentMtime = localFileInfo.metadataChangeTime();
QCOMPARE(currentMtime, expectedMtime);
}

/**
* Checks whether subsequent large uploads are skipped after a 507 error
*/
Expand Down

0 comments on commit 23f53cf

Please sign in to comment.