diff --git a/src/main/java/com/owncloud/android/MainApp.java b/src/main/java/com/owncloud/android/MainApp.java index f9788f9315..e7d0f1e7a2 100644 --- a/src/main/java/com/owncloud/android/MainApp.java +++ b/src/main/java/com/owncloud/android/MainApp.java @@ -128,13 +128,11 @@ public class MainApp extends MultiDexApplication { PreferenceManager.setAutoUploadSplitEntries(this, true); } - if (JobManager.instance().getAllJobRequestsForTag(FilesSyncJob.TAG).isEmpty()) { - new JobRequest.Builder(FilesSyncJob.TAG) - .setPeriodic(900000L, 300000L) - .setUpdateCurrent(true) - .build() - .schedule(); - } + new JobRequest.Builder(FilesSyncJob.TAG) + .setPeriodic(900000L, 300000L) + .setUpdateCurrent(true) + .build() + .schedule(); FilesSyncHelper.restartJobsIfNeeded(); @@ -357,9 +355,7 @@ public class MainApp extends MultiDexApplication { } } - for (Long idValue : syncedFolders.values()) { - ids.add(idValue); - } + ids.addAll(syncedFolders.values()); if (ids.size() > 0) { syncedFolderProvider.deleteSyncedFoldersNotInList(mContext, ids); diff --git a/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java b/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java index 127c921341..4d713b92f7 100644 --- a/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java +++ b/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java @@ -27,7 +27,6 @@ import android.net.Uri; import com.owncloud.android.db.ProviderMeta; import com.owncloud.android.lib.common.utils.Log_OC; -import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -44,21 +43,16 @@ public class FilesystemDataProvider { this.contentResolver = contentResolver; } - public void updateFilesInList(Object[] paths, String syncedFolderId) { + public void updateFilesystemFileAsSentForUpload(String path, String syncedFolderId) { ContentValues cv = new ContentValues(); cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_SENT_FOR_UPLOAD, 1); - String[] stringPaths = new String[paths.length]; - for (int i = 0; i < paths.length; i++) { - stringPaths[i] = (String) paths[i]; - } - contentResolver.update( ProviderMeta.ProviderTableMeta.CONTENT_URI_FILESYSTEM, cv, ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_LOCAL_PATH + " IN (?) and " + ProviderMeta.ProviderTableMeta.FILESYSTEM_SYNCED_FOLDER_ID + " = ?", - new String[]{Arrays.toString(stringPaths), syncedFolderId} + new String[]{path, syncedFolderId} ); } @@ -99,31 +93,6 @@ public class FilesystemDataProvider { } - public long countFilesThatNeedUploadInFolder(String localPath) { - String likeParam = localPath + "%"; - - Cursor cursor = contentResolver.query( - ProviderMeta.ProviderTableMeta.CONTENT_URI_FILESYSTEM, - new String[]{"count(*)"}, - ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_LOCAL_PATH + " LIKE ?", - new String[]{likeParam}, - null); - - if (cursor != null) { - if (cursor.getCount() == 0) { - cursor.close(); - return 0; - } else { - cursor.moveToFirst(); - int result = cursor.getInt(0); - cursor.close(); - return result; - } - } else { - return 0; - } - } - public void storeOrUpdateFileValue(String localPath, long modifiedAt, boolean isFolder, SyncedFolder syncedFolder, boolean dryRun) { diff --git a/src/main/java/com/owncloud/android/jobs/FilesSyncJob.java b/src/main/java/com/owncloud/android/jobs/FilesSyncJob.java index 0acb15ddf0..2b2d37a76a 100644 --- a/src/main/java/com/owncloud/android/jobs/FilesSyncJob.java +++ b/src/main/java/com/owncloud/android/jobs/FilesSyncJob.java @@ -125,7 +125,7 @@ public class FilesSyncJob extends Job { .build() .schedule(); - filesystemDataProvider.updateFilesInList(new Object[]{path}, + filesystemDataProvider.updateFilesystemFileAsSentForUpload(path, Long.toString(syncedFolder.getId())); } } diff --git a/src/main/java/com/owncloud/android/jobs/NewAutoUploadJob.java b/src/main/java/com/owncloud/android/jobs/NewAutoUploadJob.java index 7647f423df..443cbeb0c1 100644 --- a/src/main/java/com/owncloud/android/jobs/NewAutoUploadJob.java +++ b/src/main/java/com/owncloud/android/jobs/NewAutoUploadJob.java @@ -188,7 +188,7 @@ public class NewAutoUploadJob extends Job { } // set them as sent for upload - //filesystemDataProvider.updateFilesInList(pathsToSet.toArray()); + //filesystemDataProvider.updateFilesystemFileAsSentForUpload(pathsToSet.toArray()); wakeLock.release();*/ return Result.SUCCESS;