Perform DB scan earlier and reuse result

* Remove potentially redundant applicability check of a path if this is already in the database. This is a manual merge of #2525
This commit is contained in:
abraunegg 2024-01-14 07:17:25 +11:00
parent 5dee97700e
commit 635102e8af

View file

@ -4011,6 +4011,11 @@ class SyncEngine {
if (canFind(pathFakeDeletedArray, path)) return;
}
// Check if item if found in database
bool itemFoundInDB = pathFoundInDatabase(path);
// If the item is already found in the database, it is redundant to perform these checks
if (!itemFoundInDB) {
// This not a Client Side Filtering check, nor a Microsoft Check, but is a sanity check that the path provided is UTF encoded correctly
// Check the std.encoding of the path against: Unicode 5.0, ASCII, ISO-8859-1, ISO-8859-2, WINDOWS-1250, WINDOWS-1251, WINDOWS-1252
if (!unwanted) {
@ -4041,15 +4046,13 @@ class SyncEngine {
if (!unwanted) {
unwanted = checkPathAgainstMicrosoftNamingRestrictions(path);
}
}
if (!unwanted) {
// At this point, this path, we want to scan for new data as it is not excluded
if (isDir(path)) {
// Check if this path in the database
bool directoryFoundInDB = pathFoundInDatabase(path);
// Was the path found in the database?
if (!directoryFoundInDB) {
if (!itemFoundInDB) {
// Path not found in database when searching all drive id's
if (!cleanupLocalFiles) {
// --download-only --cleanup-local-files not used
@ -4136,10 +4139,8 @@ class SyncEngine {
// pipes - whilst technically valid files, are not valid for this client
// prw-rw-r--. 1 user user 0 Jul 7 05:55 my_pipe
if (isFile(path)) {
// Path is a valid file, not a pipe
bool fileFoundInDB = pathFoundInDatabase(path);
// Was the file found in the database?
if (!fileFoundInDB) {
if (!itemFoundInDB) {
// File not found in database when searching all drive id's
// Do we upload the file or clean up the file?
if (!cleanupLocalFiles) {