Uploaded image for project: 'Picard'
  1. Picard
  2. PICARD-2021

SameFileError when moving files between network path and local path on Windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 2.5.3
    • 2.5.2
    • File Move & Rename
    • None
    • Windows

      This is a bit special. You need:

      1. A local music folder, e.g. C:\Music
      2. This music folder also shared via network, e.g. \\mypc\Music
      3. A music file in this folder, e.g. test.mp3

      To reproduce:
      1. Enable move files and set the target directory to \\mypc\Music
      2. Load the file using the local path "C:\Music\test.mp3"
      3. Save the file

      Saving will result in a shutil.move(r"C:\Music\test.mp3", r"\\mypc\Music\test.mp3")

      Both C:\Music\test.mp3 and \\mypc\Music\test.mp3 are different paths, but refer to the very same file. shutil.move will fail with a SameFileError

      E: 09:14:17,143 util.thread.run:64: Traceback (most recent call last):
      File "C:\Program Files\Python38\lib\shutil.py", line 788, in move
      os.rename(src, real_dst)
      OSError: [WinError 17] The system cannot move the file to a different disk drive: 'C:\\Users\\Developer\\Music\\Library
      Nine Inch Nails
      Ghosts I-IV
      01 1 Ghosts I.mp3' -> '\\\\DEVEL-PC\\Users\\Developer\\Music\\Library
      Nine Inch Nails
      Ghosts I-IV
      01 1 Ghosts I.mp3'

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File ".\picard\util\thread.py", line 60, in run
      result = self.func()
      File ".\picard\file.py", line 327, in _save_and_rename
      new_filename = self._rename(old_filename, metadata)
      File ".\picard\file.py", line 499, in _rename
      move_ensure_casing(old_filename, new_filename)
      File ".\picard\util\filenaming.py", line 468, in move_ensure_casing
      shutil.move(source_path, target_path)
      File "C:\Program Files\Python38\lib\shutil.py", line 802, in move
      copy_function(src, real_dst)
      File "C:\Program Files\Python38\lib\shutil.py", line 432, in copy2
      copyfile(src, dst, follow_symlinks=follow_symlinks)
      File "C:\Program Files\Python38\lib\shutil.py", line 241, in copyfile
      raise SameFileError("

      {!r} and {!r}

      are the same file".format(src, dst))
      shutil.SameFileError: 'C:\\Users\\Developer\\Music\\Library
      Nine Inch Nails
      Ghosts I-IV
      01 1 Ghosts I.mp3' and '\\\\DEVEL-PC\\Users\\Developer\\Music\\Library
      Nine Inch Nails
      Ghosts I-IV
      01 1 Ghosts I.mp3' are the same file

            outsidecontext Philipp Wolfer
            outsidecontext Philipp Wolfer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                Version Package
                2.5.3