@@ -102,20 +102,24 @@ class SyncService(
102102            //  Remove previous errors
103103            errorDao.deleteAll()
104104
105+             //  Just make sure webdav server is properly responding before starting
106+             webDavService.getProperties(CollectionPath (" /"  ))
107+ 
105108            //  Resync already synced files
106109            fileDao.getAllPathnames().forEach {
107110                DbFileSyncWorker .enqueue(context, it, immediate)
108111            }
109112
110113            //  Sync only new files from local
111-             mediaStoreService.getAllIds(getPathExclusions()).subtract(fileDao.getAllids().toSet()).forEach {
112-                 MediastoreIdSyncWorker .enqueue(
113-                     context,
114-                     it,
115-                     immediate =  immediate,
116-                     skipIfInDb =  true 
117-                 )
118-             }
114+             mediaStoreService.getAllIds(getPathExclusions()).subtract(fileDao.getAllids().toSet())
115+                 .forEach {
116+                     MediastoreIdSyncWorker .enqueue(
117+                         context,
118+                         it,
119+                         immediate =  immediate,
120+                         skipIfInDb =  true 
121+                     )
122+                 }
119123
120124            //  Sync new files from distant
121125            DavSyncWorker .enqueue(context, " /"  , immediate =  immediate, isCollection =  true )
@@ -201,7 +205,8 @@ class SyncService(
201205                webDavService.mkcolRecursive(CollectionPath (mediaStoreFile.relativePath))
202206                webDavService.move(davFilePath, mediaStoreDavFilePath)
203207                val  newDavFileProperties =  webDavService.getProperties(mediaStoreDavFilePath)
204-                 val  newDbFile =  createDbFile(mediaStoreFile, newDavFileProperties, isCollection =  false )
208+                 val  newDbFile = 
209+                     createDbFile(mediaStoreFile, newDavFileProperties, isCollection =  false )
205210                fileDao.insertAll(newDbFile)
206211            } else  {
207212                uploadFile(mediaStoreFile, mediaStoreDavFilePath, null )
0 commit comments