More robust instant photo uploads
[pub/Android/ownCloud.git] / src / com / owncloud / android / syncadapter / FileSyncAdapter.java
index f7bfa43..1a3afe6 100644 (file)
@@ -91,7 +91,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
 \r
         sendStickyBroadcast(true, null);  // message to signal the start to the UI\r
 \r
-        PropFindMethod query;\r
+        PropFindMethod query = null;\r
         try {\r
             mCurrentSyncTime = System.currentTimeMillis();\r
             query = new PropFindMethod(getUri().toString() + "/");\r
@@ -123,6 +123,10 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             // TODO update syncResult\r
             Log.e(TAG, "problem while synchronizing owncloud account " + account.name, t);\r
             t.printStackTrace();\r
+            \r
+        } finally {\r
+            if (query != null)\r
+                query.releaseConnection();  // let the connection available for other methods\r
         }\r
         \r
         /*  Commented code for ugly performance tests\r
@@ -150,11 +154,12 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
     }\r
 \r
     private void fetchData(String uri, SyncResult syncResult, long parentId) {\r
+        PropFindMethod query = null;\r
         try {\r
             Log.d(TAG, "fetching " + uri);\r
             \r
             // remote request \r
-            PropFindMethod query = new PropFindMethod(uri);\r
+            query = new PropFindMethod(uri);\r
             /*  Commented code for ugly performance tests\r
             long responseDelay = System.currentTimeMillis();\r
             */\r
@@ -236,8 +241,6 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             if (mDelaysIndex >= MAX_DELAYS)\r
                 mDelaysIndex = 0;\r
              */\r
-            \r
-\r
 \r
         } catch (OperationCanceledException e) {\r
             e.printStackTrace();\r
@@ -254,6 +257,10 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             // TODO update syncResult\r
             Log.e(TAG, "problem while synchronizing owncloud account " + mAccount.name, t);\r
             t.printStackTrace();\r
+            \r
+        } finally {\r
+            if (query != null)\r
+                query.releaseConnection();  // let the connection available for other methods\r
         }\r
     }\r
 \r