Skip to content

Conversation

nilsding
Copy link
Member

@nilsding nilsding commented Jul 31, 2025

only basic support for now: schedule a folder to sync if any of the received fileids is known.

the current WIP implementation has an issue though: if a file/folder was created in the sync folder root, that folder will not be synced even though that root folder's fileid is part of the list received through the notification

@nilsding nilsding self-assigned this Jul 31, 2025
@nilsding nilsding added this to the 3.18.0 milestone Jul 31, 2025
static constexpr int MAX_ALLOWED_FAILED_AUTHENTICATION_ATTEMPTS = 3;
static constexpr int PING_INTERVAL = 30 * 1000;

static constexpr QLatin1String NOTIFY_FILE_ID_PREFIX = QLatin1String{"notify_file_id "};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this space at the end intended?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes
the push notification received looks like:

notify_file_id [1,2,3,156,6456,269243]

I think parsing that array would even work with the trailing space

Comment on lines +1700 to +1785
SqlQuery query(
QLatin1String{"SELECT 1 FROM metadata WHERE ROUND(fileid) IN (%1) LIMIT 1;"}
.arg(fileIdStrings.join(QLatin1String{", "})).toLocal8Bit(),
_db
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use a prepared SQL request with SQL placeholders ?
for example https://github.com/nextcloud/desktop/blob/master/src/common/syncjournaldb.cpp#L1111-L1121

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how useful the prepared SQL query would be in this case as there is simply no way to bind an array to a single placeholder, and the passed fileIds array does not have a consistent size. I would also rather avoid to have query each possible fileid one after the other until at least one entry was found...

[[nodiscard]] bool updateLocalMetadata(const QString &filename,
qint64 modtime, qint64 size, quint64 inode, const SyncJournalFileLockInfo &lockInfo);

[[nodiscard]] bool hasFileIds(const QList<qint64> &fileIds);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be const ?

continue;
}

if (!folder->journalDb()->hasFileIds(fileIds)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any reason to use this apart from when using selective synchronization ?
did you checked that the request is fast enough ?

@nilsding nilsding force-pushed the feature/notify-file-ids branch from a44cead to a2a4ae9 Compare August 4, 2025 15:05
For this to work we also now need to store the fileId from the sync root
folder, otherwise we would never know about new files inside the
configured sync root

Signed-off-by: Jyrki Gadinger <[email protected]>
@nilsding nilsding force-pushed the feature/notify-file-ids branch from a2a4ae9 to 5eb8f40 Compare September 23, 2025 12:51
Copy link

Artifact containing the AppImage: nextcloud-appimage-pr-8502.zip

Digest: sha256:bab306fe790c68baf1c7657b45e5ad6af066d74ac98d081a5ea2676a6dc8509a

To test this change/fix you can download the above artifact file, unzip it, and run it.

Please make sure to quit your existing Nextcloud app and backup your data.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
7 Security Hotspots
51.9% Coverage on New Code (required ≥ 80%)
2 New Bugs (required ≤ 0)
E Reliability Rating on New Code (required ≥ A)
E Maintainability Rating on New Code (required ≥ A)
216 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@Rello Rello moved this to 📄 To do in 💻 Desktop Clients team Sep 24, 2025
@Rello Rello modified the milestones: 4.0.0, 4.1.0 Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📄 To do
Development

Successfully merging this pull request may close these issues.

3 participants