X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/a4ba6170ea7696e085b07adfef73eeb8b77cb8e2..ba148a82782bba94b95b8acd2ecb19af797fa84a:/src/com/owncloud/android/syncadapter/FileSyncAdapter.java diff --git a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java index f7bfa432..7b803fc1 100644 --- a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java +++ b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java @@ -91,7 +91,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { sendStickyBroadcast(true, null); // message to signal the start to the UI - PropFindMethod query; + PropFindMethod query = null; try { mCurrentSyncTime = System.currentTimeMillis(); query = new PropFindMethod(getUri().toString() + "/"); @@ -123,6 +123,10 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { // TODO update syncResult Log.e(TAG, "problem while synchronizing owncloud account " + account.name, t); t.printStackTrace(); + + } finally { + if (query != null) + query.releaseConnection(); // let the connection available for other methods } /* Commented code for ugly performance tests @@ -150,11 +154,12 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { } private void fetchData(String uri, SyncResult syncResult, long parentId) { + PropFindMethod query = null; try { Log.d(TAG, "fetching " + uri); // remote request - PropFindMethod query = new PropFindMethod(uri); + query = new PropFindMethod(uri); /* Commented code for ugly performance tests long responseDelay = System.currentTimeMillis(); */ @@ -205,11 +210,12 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { Vector files = getStorageManager().getDirectoryContent( getStorageManager().getFileById(parentId)); OCFile file; + String currentSavePath = FileDownloader.getSavePath(mAccount.name); for (int i=0; i < files.size(); ) { file = files.get(i); if (file.getLastSyncDate() != mCurrentSyncTime) { Log.v(TAG, "removing file: " + file); - getStorageManager().removeFile(file); + getStorageManager().removeFile(file, (file.isDown() && file.getStoragePath().startsWith(currentSavePath))); files.remove(i); } else { i++; @@ -236,8 +242,6 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { if (mDelaysIndex >= MAX_DELAYS) mDelaysIndex = 0; */ - - } catch (OperationCanceledException e) { e.printStackTrace(); @@ -254,6 +258,10 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { // TODO update syncResult Log.e(TAG, "problem while synchronizing owncloud account " + mAccount.name, t); t.printStackTrace(); + + } finally { + if (query != null) + query.releaseConnection(); // let the connection available for other methods } }