fxdeniz / NeSync

Local file sync & backups
GNU General Public License v3.0
31 stars 2 forks source link

`FileSystemEventDb::addFolder()` does not release lock on `Folder` table in windows(os) #133

Closed fxdeniz closed 1 year ago

fxdeniz commented 1 year ago

FileSystemEventDb::addFolder() locks table Folder and causes other instances of FileSystemEventDb get stuck. I only observed this behavior on Windows, in Linux everything works as expected.

This is probably related with transaction in FileSystemEventDb::addFolder(). Somehow, transaction management in FileSystemEventDb::addFolder() trigers this problem, and calling FileSystemEventDb::addFolder() in FileSystemEventDb::addFile() further complicates things.

I observed these, when FileSystemEventDb::addFolder() locks the database:

fxdeniz commented 1 year ago

in 50d60deed62761f196e6317310ec33a934e6d064 I added a workaround. By adding

database.close();
database.open();

beginning, I'm probably preventing cyclic lock. When close() is called on QSqlDatabase, it destroys all of it's children QSqlQuery objects. Because all QSqlQuery objects are destroyed, lock is released on table Folder.

Finding better lock releasing mechanism or re-designing FileSystemEventDb::addFolder() and FileSystemEventDb::addFile() will solve the issue completely.

50d60deed62761f196e6317310ec33a934e6d064 currently works perfectly but beginning of the code looks weird.