Fixed a race condition duw to which renamed shared folders continued showing in mysha...
[pithos-web-client] / src / gr / grnet / pithos / web / client / commands / PasteCommand.java
index 8fd5d8b..6ae2669 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 GRNET S.A. All rights reserved.
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or
  * without modification, are permitted provided that the following
@@ -48,6 +48,7 @@ import java.util.List;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.http.client.Response;
+import com.google.gwt.http.client.URL;
 import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.ui.PopupPanel;
 
@@ -94,7 +95,7 @@ public class PasteCommand implements Command {
                     @Override
                     public void execute() {
                         app.getClipboard().clear();
-                        app.deleteFolder(tobeCopied);
+                        app.deleteFolder(tobeCopied, null);
                         app.updateFolder(folder, true, null);
                     }
                 });
@@ -137,13 +138,14 @@ public class PasteCommand implements Command {
             String path = folder.getUri() + "/" + file.getName();
             PutRequest copyFile = new PutRequest(app.getApiPath(), folder.getOwner(), path) {
                 @Override
-                public void onSuccess(@SuppressWarnings("unused") Resource result) {
+                public void onSuccess(Resource result) {
                     moveFiles(iter, callback);
                 }
 
                 @Override
                 public void onError(Throwable t) {
                     GWT.log("", t);
+                                       app.setError(t);
                     if (t instanceof RestException) {
                         app.displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
                     }
@@ -157,7 +159,8 @@ public class PasteCommand implements Command {
                                }
             };
             copyFile.setHeader("X-Auth-Token", app.getToken());
-            copyFile.setHeader("X-Move-From", file.getUri());
+            copyFile.setHeader("X-Move-From", URL.encodePathSegment(file.getUri()));
+            copyFile.setHeader("Content-Type", file.getContentType());
             Scheduler.get().scheduleDeferred(copyFile);
         }
         else if (callback != null) {