Loading app/src/main/java/foundation/e/drive/operations/DownloadFileRemoteOperation.java +9 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ */ package foundation.e.drive.operations; import android.util.Log; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.network.WebdavUtils; import com.owncloud.android.lib.common.operations.OperationCancelledException; Loading Loading @@ -74,7 +76,13 @@ class DownloadFileRemoteOperation extends RemoteOperation { File tmpFile = new File(getTmpPath()); /// perform the download try { tmpFile.getParentFile().mkdirs(); File parentFile = tmpFile.getParentFile(); if (parentFile == null) { Log.e(TAG, "getParentFile() returned null. Returning to prevent a NPE"); return new RemoteOperationResult(RemoteOperationResult.ResultCode.UNKNOWN_ERROR); } parentFile.mkdirs(); int status = downloadFile(client, tmpFile); result = new RemoteOperationResult(isSuccess(status), mGet); Log_OC.i(TAG, "Download of " + mRemotePath + " to " + getTmpPath() + ": " + Loading app/src/main/java/foundation/e/drive/operations/ListFileRemoteOperation.java +20 −5 Original line number Diff line number Diff line Loading @@ -65,8 +65,14 @@ public class ListFileRemoteOperation extends RemoteOperation { SyncedFolder syncedFolder = mSyncedFolderIterator.next(); //if folder is media type() && is an hidden folder then ignore it String fileName = CommonUtils.getFileNameFromPath(syncedFolder.getRemoteFolder()); if (fileName == null) { Log.e(TAG, "getFileNameFromPath() returned null. Returning to prevent a NPE"); return new RemoteOperationResult(RemoteOperationResult.ResultCode.UNKNOWN_ERROR); } if(syncedFolder.isMediaType() && CommonUtils.getFileNameFromPath(syncedFolder.getRemoteFolder()).startsWith(".")){ && fileName.startsWith(".")){ mSyncedFolderIterator.remove(); continue; } Loading Loading @@ -107,8 +113,13 @@ public class ListFileRemoteOperation extends RemoteOperation { //if remoteFile is in a "media" folder and its name start with "." // then ignore it if(syncedFolder.isMediaType() && CommonUtils.getFileNameFromPath( remoteFile.getRemotePath() ).startsWith(".") ){ fileName = CommonUtils.getFileNameFromPath(remoteFile.getRemotePath()); if (fileName == null) { Log.e(TAG, "getFileNameFromPath() returned null. Returning to prevent NPE"); return new RemoteOperationResult(RemoteOperationResult.ResultCode.UNKNOWN_ERROR); } if(syncedFolder.isMediaType() && fileName.startsWith(".") ){ continue; } if( remoteFile.getMimeType().equals("DIR") ) { Loading Loading @@ -140,9 +151,13 @@ public class ListFileRemoteOperation extends RemoteOperation { syncedFolder.setToSync(true); //If there is no remote file, then try to delete local one if empty. Finally remove Synced Folder from DB. File localFolder = new File(syncedFolder.getLocalFolder()); if(localFolder.exists() && localFolder.listFiles().length == 0){ if (localFolder.exists()) { File[] arrayFiles = localFolder.listFiles(); if (arrayFiles != null && arrayFiles.length == 0) { localFolder.delete(); } } if( !localFolder.exists() ) { if (syncedFolder.getId() > this.initialFolderNumber/*-1*/) { //does the synced folder has been persisted? //remove it from DB Loading app/src/main/java/foundation/e/drive/services/ObserverService.java +18 −3 Original line number Diff line number Diff line Loading @@ -166,8 +166,17 @@ public class ObserverService extends Service implements OnRemoteOperationListene */ private void deleteOldestCrashlogs(){ Log.i(TAG, "deleteOldestCrashLogs()"); File[] fileToRemove = getExternalFilesDir(ServiceExceptionHandler.CRASH_LOG_FOLDER) .listFiles(new CrashlogsFileFilter()); File externalFilesDir = getExternalFilesDir(ServiceExceptionHandler.CRASH_LOG_FOLDER); if (externalFilesDir == null) { Log.e(TAG, "getExternalFilesDir() returned null. Returning to prevent a NPE"); return; } File[] fileToRemove = externalFilesDir.listFiles(new CrashlogsFileFilter()); if (fileToRemove == null) { Log.e(TAG, "getExternalFilesDir() returned null. Returning to prevent a NPE"); return; } int counter = 0; for (File file : fileToRemove) { Loading Loading @@ -551,7 +560,13 @@ public class ObserverService extends Service implements OnRemoteOperationListene Log.d(TAG, "SyncedFolder :"+syncedFolder.getLibelle()+", "+syncedFolder.getLocalFolder()+", "+syncedFolder.getLastModified()+", "+syncedFolder.isScanLocal()+", "+syncedFolder.getId() ); //Check it's not a hidden file if (syncedFolder.isMediaType() && CommonUtils.getFileNameFromPath(syncedFolder.getLocalFolder()).startsWith(".")){ String fileName = CommonUtils.getFileNameFromPath(syncedFolder.getLocalFolder()); if (fileName == null) { Log.e(TAG, "getFileNameFromPath() returned null. Returning to prevent a NPE"); return; } if (syncedFolder.isMediaType() && fileName.startsWith(".")){ iterator.remove(); continue; } Loading app/src/main/java/foundation/e/drive/services/ResetService.java +5 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,11 @@ public class ResetService extends Service { private void removeCachedFiles() { File[] cachedFiles = this.getApplicationContext().getExternalCacheDir().listFiles(); if (cachedFiles == null) { Log.e(TAG, "listFiles() returned null. Returning to prevent a NPE"); return; } for (File f : cachedFiles) { f.delete(); } Loading Loading
app/src/main/java/foundation/e/drive/operations/DownloadFileRemoteOperation.java +9 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ */ package foundation.e.drive.operations; import android.util.Log; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.network.WebdavUtils; import com.owncloud.android.lib.common.operations.OperationCancelledException; Loading Loading @@ -74,7 +76,13 @@ class DownloadFileRemoteOperation extends RemoteOperation { File tmpFile = new File(getTmpPath()); /// perform the download try { tmpFile.getParentFile().mkdirs(); File parentFile = tmpFile.getParentFile(); if (parentFile == null) { Log.e(TAG, "getParentFile() returned null. Returning to prevent a NPE"); return new RemoteOperationResult(RemoteOperationResult.ResultCode.UNKNOWN_ERROR); } parentFile.mkdirs(); int status = downloadFile(client, tmpFile); result = new RemoteOperationResult(isSuccess(status), mGet); Log_OC.i(TAG, "Download of " + mRemotePath + " to " + getTmpPath() + ": " + Loading
app/src/main/java/foundation/e/drive/operations/ListFileRemoteOperation.java +20 −5 Original line number Diff line number Diff line Loading @@ -65,8 +65,14 @@ public class ListFileRemoteOperation extends RemoteOperation { SyncedFolder syncedFolder = mSyncedFolderIterator.next(); //if folder is media type() && is an hidden folder then ignore it String fileName = CommonUtils.getFileNameFromPath(syncedFolder.getRemoteFolder()); if (fileName == null) { Log.e(TAG, "getFileNameFromPath() returned null. Returning to prevent a NPE"); return new RemoteOperationResult(RemoteOperationResult.ResultCode.UNKNOWN_ERROR); } if(syncedFolder.isMediaType() && CommonUtils.getFileNameFromPath(syncedFolder.getRemoteFolder()).startsWith(".")){ && fileName.startsWith(".")){ mSyncedFolderIterator.remove(); continue; } Loading Loading @@ -107,8 +113,13 @@ public class ListFileRemoteOperation extends RemoteOperation { //if remoteFile is in a "media" folder and its name start with "." // then ignore it if(syncedFolder.isMediaType() && CommonUtils.getFileNameFromPath( remoteFile.getRemotePath() ).startsWith(".") ){ fileName = CommonUtils.getFileNameFromPath(remoteFile.getRemotePath()); if (fileName == null) { Log.e(TAG, "getFileNameFromPath() returned null. Returning to prevent NPE"); return new RemoteOperationResult(RemoteOperationResult.ResultCode.UNKNOWN_ERROR); } if(syncedFolder.isMediaType() && fileName.startsWith(".") ){ continue; } if( remoteFile.getMimeType().equals("DIR") ) { Loading Loading @@ -140,9 +151,13 @@ public class ListFileRemoteOperation extends RemoteOperation { syncedFolder.setToSync(true); //If there is no remote file, then try to delete local one if empty. Finally remove Synced Folder from DB. File localFolder = new File(syncedFolder.getLocalFolder()); if(localFolder.exists() && localFolder.listFiles().length == 0){ if (localFolder.exists()) { File[] arrayFiles = localFolder.listFiles(); if (arrayFiles != null && arrayFiles.length == 0) { localFolder.delete(); } } if( !localFolder.exists() ) { if (syncedFolder.getId() > this.initialFolderNumber/*-1*/) { //does the synced folder has been persisted? //remove it from DB Loading
app/src/main/java/foundation/e/drive/services/ObserverService.java +18 −3 Original line number Diff line number Diff line Loading @@ -166,8 +166,17 @@ public class ObserverService extends Service implements OnRemoteOperationListene */ private void deleteOldestCrashlogs(){ Log.i(TAG, "deleteOldestCrashLogs()"); File[] fileToRemove = getExternalFilesDir(ServiceExceptionHandler.CRASH_LOG_FOLDER) .listFiles(new CrashlogsFileFilter()); File externalFilesDir = getExternalFilesDir(ServiceExceptionHandler.CRASH_LOG_FOLDER); if (externalFilesDir == null) { Log.e(TAG, "getExternalFilesDir() returned null. Returning to prevent a NPE"); return; } File[] fileToRemove = externalFilesDir.listFiles(new CrashlogsFileFilter()); if (fileToRemove == null) { Log.e(TAG, "getExternalFilesDir() returned null. Returning to prevent a NPE"); return; } int counter = 0; for (File file : fileToRemove) { Loading Loading @@ -551,7 +560,13 @@ public class ObserverService extends Service implements OnRemoteOperationListene Log.d(TAG, "SyncedFolder :"+syncedFolder.getLibelle()+", "+syncedFolder.getLocalFolder()+", "+syncedFolder.getLastModified()+", "+syncedFolder.isScanLocal()+", "+syncedFolder.getId() ); //Check it's not a hidden file if (syncedFolder.isMediaType() && CommonUtils.getFileNameFromPath(syncedFolder.getLocalFolder()).startsWith(".")){ String fileName = CommonUtils.getFileNameFromPath(syncedFolder.getLocalFolder()); if (fileName == null) { Log.e(TAG, "getFileNameFromPath() returned null. Returning to prevent a NPE"); return; } if (syncedFolder.isMediaType() && fileName.startsWith(".")){ iterator.remove(); continue; } Loading
app/src/main/java/foundation/e/drive/services/ResetService.java +5 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,11 @@ public class ResetService extends Service { private void removeCachedFiles() { File[] cachedFiles = this.getApplicationContext().getExternalCacheDir().listFiles(); if (cachedFiles == null) { Log.e(TAG, "listFiles() returned null. Returning to prevent a NPE"); return; } for (File f : cachedFiles) { f.delete(); } Loading