Commit dae22082 authored by vince-bourgmayer's avatar vince-bourgmayer
Browse files

add method to remove oldestCrashlogs. add CrashlogsFileFilter with unitTest class.

parent 563c9965
package foundation.e.drive.fileFilters;
public class CrashlogsFileFilter {
}
......@@ -37,6 +37,7 @@ import java.util.ListIterator;
import java.util.Map;
import foundation.e.drive.database.DbHelper;
import foundation.e.drive.fileFilters.CrashlogsFileFilter;
import foundation.e.drive.fileFilters.FileFilterFactory;
import foundation.e.drive.fileFilters.OnlyFileFilter;
import foundation.e.drive.models.SyncedFolder;
......@@ -151,12 +152,36 @@ public class ObserverService extends Service implements OnRemoteOperationListene
Log.i(TAG, "begin()");
this.isWorking = true;
clearCachedFile();
deleteOldestCrashlogs();
startScan(true);
}
/**
* This method remove all the crash-logs file
* in external dir that are 10 days or more old.
*/
private void deleteOldestCrashlogs(){
Log.i(TAG, "deleteOldestCrashLogs()");
File[] fileToRemove = getExternalFilesDir(ServiceExceptionHandler.CRASH_LOG_FOLDER)
.listFiles(new CrashlogsFileFilter());
int counter = 0;
for (File file : fileToRemove) {
try {
file.delete();
++counter;
}catch (SecurityException e){
e.printStackTrace();
}
}
Log.d(TAG, counter+" old crashlogs file.s deleted");
}
/**
* Clear cached file unused:
* remove each cached file which isn't in OperationManagerService.lockedSyncedFileState();
* @TODO rewrite this method!
*/
private void clearCachedFile(){
Log.i(TAG, "clearCachedFile()");
......
package foundation.e.drive.Test.FileFilterTest;
public class CrashlogFileFilterTest {
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment