Use shutil.move() instead of os.replace/rename
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
# along with whipper. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
"""Rename files on file system and inside metafiles in a resumable way."""
|
||||
@@ -168,7 +169,7 @@ class RenameFile(Operation):
|
||||
assert not os.path.exists(self._destination)
|
||||
|
||||
def do(self):
|
||||
os.rename(self._source, self._destination)
|
||||
shutil.move(self._source, self._destination)
|
||||
|
||||
def serialize(self):
|
||||
return '"%s" "%s"' % (self._source, self._destination)
|
||||
@@ -203,7 +204,7 @@ class RenameInFile(Operation):
|
||||
s.replace(self._source, self._destination).encode())
|
||||
|
||||
os.close(fd)
|
||||
os.rename(name, self._path)
|
||||
shutil.move(name, self._path)
|
||||
|
||||
def serialize(self):
|
||||
return '"%s" "%s" "%s"' % (self._path, self._source, self._destination)
|
||||
|
||||
@@ -535,7 +535,7 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
|
||||
if not self.exception:
|
||||
try:
|
||||
logger.debug('moving to final path %r', self.path)
|
||||
os.rename(self._tmppath, self.path)
|
||||
shutil.move(self._tmppath, self.path)
|
||||
# FIXME: catching too general exception (Exception)
|
||||
except Exception as e:
|
||||
logger.debug('exception while moving to final '
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
from tempfile import NamedTemporaryFile
|
||||
@@ -80,7 +81,7 @@ class CoverArtTestCase(unittest.TestCase):
|
||||
with NamedTemporaryFile(suffix='.cover.jpg', delete=False) as f:
|
||||
f.write(data)
|
||||
os.chmod(f.name, 0o644)
|
||||
os.replace(f.name, cover_art_path)
|
||||
shutil.move(f.name, cover_art_path)
|
||||
return cover_art_path
|
||||
|
||||
def testCoverArtPath(self):
|
||||
|
||||
Reference in New Issue
Block a user