Skip to content

Commit ecc45d4

Browse files
committed
Just make sure webdav server is properly responding before starting full sync
1 parent 64db4a8 commit ecc45d4

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

.idea/deploymentTargetSelector.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/phpbg/easysync/worker/SyncService.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)