@@ -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
@@ -60,27 +59,19 @@ class FileSystemRepository(
6059 val entities = dao.getAutoUploadFilesEntities(syncedFolderId, BATCH_SIZE , lastId)
6160 val filtered = mutableListOf<Pair <String , Int >>()
6261
63- entities.forEach { entity ->
64- entity.localPath?.let { path ->
65- val file = File (path)
66- if (! file.exists()) {
67- Log_OC .w(TAG , " Ignoring file for upload (doesn't exist): $path " )
68- deleteAutoUploadAndUploadEntity(syncedFolder, path, entity)
69- } else if (! SyncedFolderUtils .isQualifiedFolder(file.parent)) {
70- Log_OC .w(TAG , " Ignoring file for upload (unqualified folder): $path " )
71- deleteAutoUploadAndUploadEntity(syncedFolder, path, entity)
72- } else if (! SyncedFolderUtils .isFileNameQualifiedForAutoUpload(file.name)) {
73- Log_OC .w(TAG , " Ignoring file for upload (unqualified file): $path " )
74- deleteAutoUploadAndUploadEntity(syncedFolder, path, entity)
75- } else {
76- Log_OC .d(TAG , " Adding path to upload: $path " )
62+ for (entity in entities) {
63+ val file = SyncedFolderUtils .validateForAutoUpload(entity.localPath)
64+ if (file == null ) {
65+ deleteAutoUploadAndUploadEntity(syncedFolder, entity.localPath ? : " " , entity)
66+ continue
67+ }
7768
78- if ( entity.id != null ) {
79- filtered.add(path to entity.id)
80- } else {
81- Log_OC .w( TAG , " cant adding path to upload, id is null " )
82- }
83- }
69+ Log_OC .d( TAG , " Adding path to upload: ${ entity.localPath} " )
70+
71+ if (entity.id != null ) {
72+ filtered.add(entity.localPath !! to entity.id )
73+ } else {
74+ Log_OC .w( TAG , " cant adding path to upload, id is null " )
8475 }
8576 }
8677
@@ -176,7 +167,7 @@ class FileSystemRepository(
176167 checkFileType : Boolean = false
177168 ) {
178169 try {
179- val file = localPath?.toFile( )
170+ val file = SyncedFolderUtils .validateForAutoUpload(localPath )
180171 if (file == null ) {
181172 Log_OC .w(TAG , " file null, cannot insert or replace: $localPath " )
182173 return
@@ -187,7 +178,7 @@ class FileSystemRepository(
187178 return
188179 }
189180
190- val entity = dao.getFileByPathAndFolder(localPath, syncedFolder.id.toString())
181+ val entity = dao.getFileByPathAndFolder(localPath!! , syncedFolder.id.toString())
191182
192183 val fileModified = (lastModified ? : file.lastModified())
193184 val hasNotChanged = entity?.fileModified == fileModified
0 commit comments