Add comments
[pub/Android/ownCloud.git] / src / com / owncloud / android / operations / CreateShareOperation.java
index 4b2f6ad..896ecca 100644 (file)
@@ -42,6 +42,7 @@ import com.owncloud.android.utils.Log_OC;
 public class CreateShareOperation extends SyncOperation {
 
     private static final String TAG = CreateShareOperation.class.getSimpleName();
+    
 
     protected FileDataStorageManager mStorageManager;
 
@@ -91,17 +92,18 @@ public class CreateShareOperation extends SyncOperation {
         operation = new GetRemoteSharesForFileOperation(mPath, false, false);
         RemoteOperationResult result = ((GetRemoteSharesForFileOperation)operation).execute(client);
 
-        if (result.isSuccess()) {
+        if (!result.isSuccess() || result.getData().size() <= 0) {
             operation = new CreateRemoteShareOperation(mPath, mShareType, mShareWith, mPublicUpload, mPassword, mPermissions);
             result = ((CreateRemoteShareOperation)operation).execute(client);
-
-            if (result.isSuccess()) {
-                if (result.getData().size() > 0) {
-                    OCShare share = (OCShare) result.getData().get(0);
-                    updateData(share);
-                }
-            }
         }
+        
+        if (result.isSuccess()) {
+            if (result.getData().size() > 0) {
+                OCShare share = (OCShare) result.getData().get(0);
+                updateData(share);
+            } 
+        }
+        
         return result;
     }