@@ -14,7 +14,6 @@ import android.provider.MediaStore
1414import com.nextcloud.client.database.dao.FileSystemDao
1515import com.nextcloud.client.database.entity.FilesystemEntity
1616import com.nextcloud.utils.extensions.shouldSkipFile
17- import com.nextcloud.utils.extensions.toFile
1817import com.owncloud.android.datamodel.SyncedFolder
1918import com.owncloud.android.datamodel.UploadsStorageManager
2019import com.owncloud.android.lib.common.utils.Log_OC
@@ -62,27 +61,19 @@ class FileSystemRepository(
6261 val entities = dao.getAutoUploadFilesEntities(syncedFolderId, BATCH_SIZE , lastId)
6362 val filtered = mutableListOf<Pair <String , Int >>()
6463
65- entities.forEach { entity ->
66- entity.localPath?.let { path ->
67- val file = File (path)
68- if (! file.exists()) {
69- Log_OC .w(TAG , " Ignoring file for upload (doesn't exist): $path " )
70- deleteAutoUploadAndUploadEntity(syncedFolder, path, entity)
71- } else if (! SyncedFolderUtils .isQualifiedFolder(file.parent)) {
72- Log_OC .w(TAG , " Ignoring file for upload (unqualified folder): $path " )
73- deleteAutoUploadAndUploadEntity(syncedFolder, path, entity)
74- } else if (! SyncedFolderUtils .isFileNameQualifiedForAutoUpload(file.name)) {
75- Log_OC .w(TAG , " Ignoring file for upload (unqualified file): $path " )
76- deleteAutoUploadAndUploadEntity(syncedFolder, path, entity)
77- } else {
78- Log_OC .d(TAG , " Adding path to upload: $path " )
64+ for (entity in entities) {
65+ val file = SyncedFolderUtils .validateForAutoUpload(entity.localPath)
66+ if (file == null ) {
67+ deleteAutoUploadAndUploadEntity(syncedFolder, entity.localPath ? : " " , entity)
68+ continue
69+ }
7970
80- if ( entity.id != null ) {
81- filtered.add(path to entity.id)
82- } else {
83- Log_OC .w( TAG , " cant adding path to upload, id is null " )
84- }
85- }
71+ Log_OC .d( TAG , " Adding path to upload: ${ entity.localPath} " )
72+
73+ if (entity.id != null ) {
74+ filtered.add(entity.localPath !! to entity.id )
75+ } else {
76+ Log_OC .w( TAG , " cant adding path to upload, id is null " )
8677 }
8778 }
8879
@@ -178,7 +169,7 @@ class FileSystemRepository(
178169 checkFileType : Boolean = false
179170 ) {
180171 try {
181- val file = localPath?.toFile( )
172+ val file = SyncedFolderUtils .validateForAutoUpload(localPath )
182173 if (file == null ) {
183174 Log_OC .w(TAG , " file null, cannot insert or replace: $localPath " )
184175 return
@@ -189,7 +180,7 @@ class FileSystemRepository(
189180 return
190181 }
191182
192- val entity = dao.getFileByPathAndFolder(localPath, syncedFolder.id.toString())
183+ val entity = dao.getFileByPathAndFolder(localPath!! , syncedFolder.id.toString())
193184
194185 val fileModified = (lastModified ? : file.lastModified())
195186 val hasNotChanged = entity?.fileModified == fileModified
0 commit comments