patch from rustyBSD fixing file moving to other devices
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 3 Oct 2012 06:27:40 +0000 (06:27 +0000)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 3 Oct 2012 06:27:40 +0000 (06:27 +0000)
ticket #1581

SVN revision: 77342

src/bin/e_fm_op.c

index d608d4f..fb7114a 100644 (file)
@@ -260,7 +260,7 @@ main(int argc, char **argv)
                     }
                   else
                     {
-                       if (type == E_FM_OP_RENAME)
+                       if (type == E_FM_OP_MOVE)
                          {
                             if (!strcmp(argv[i], buf))
                               goto skip_arg;
@@ -269,7 +269,7 @@ main(int argc, char **argv)
                               _E_FM_OP_ERROR_SEND_SCAN(0, E_FM_OP_ERROR,
                                                        "Unknown destination '%s': %s.", buf);
                          }
-                       else if (type == E_FM_OP_MOVE)
+                       else if (type == E_FM_OP_RENAME)
                          {
                             if (!strcmp(argv[i], buf))
                               goto skip_arg;
@@ -284,7 +284,10 @@ main(int argc, char **argv)
                                   * unvoidable. */
                                  if (rename(argv[i], buf) == -1)
                                    {
-                                      if (errno != EXDEV)
+                                      /* if it's another device */
+                                      if (errno == EXDEV)
+                                        type = E_FM_OP_COPY;
+                                      else
                                         {
                                            _E_FM_OP_ERROR_SEND_SCAN(0, E_FM_OP_ERROR,
                                                                     "Cannot move '%s' to '%s': %s.",
@@ -301,6 +304,8 @@ main(int argc, char **argv)
                               }
                             else
                               {
+                                 /* if the destination file already exists,
+                                  * store a task which handles overwrite */
                                  struct stat st1;
                                  struct stat st2;
                                  if ((stat(argv[i], &st1) == 0) &&