mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-09 21:24:36 +00:00
Fixed copying operations for folders which didn't work.
This commit is contained in:
parent
d887cd118c
commit
0b20b35ffb
13
core/app.py
13
core/app.py
@ -94,7 +94,8 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
|
||||
def _get_file(self, str_path):
|
||||
path = Path(str_path)
|
||||
f = fs.get_file(path, self.directories.fileclasses)
|
||||
# We add fs.Folder to fileclasses in case the file we're loading contains folder paths.
|
||||
f = fs.get_file(path, self.directories.fileclasses + [fs.Folder])
|
||||
if f is None:
|
||||
return None
|
||||
try:
|
||||
@ -197,12 +198,7 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
while delete_if_empty(path, ['.DS_Store']):
|
||||
path = path[:-1]
|
||||
|
||||
def copy_or_move(self, dupe, copy, destination, dest_type):
|
||||
"""
|
||||
copy: True = Copy False = Move
|
||||
destination: string.
|
||||
dest_type: DestType constants
|
||||
"""
|
||||
def copy_or_move(self, dupe, copy: bool, destination: str, dest_type: DestType):
|
||||
source_path = dupe.path
|
||||
location_path = first(p for p in self.directories if dupe.path in p)
|
||||
dest_path = Path(destination)
|
||||
@ -214,6 +210,9 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
dest_path = dest_path + source_base
|
||||
if not io.exists(dest_path):
|
||||
io.makedirs(dest_path)
|
||||
# Add filename to dest_path. For file move/copy, it's not required, but for folders, yes.
|
||||
dest_path = dest_path + source_path[-1]
|
||||
logging.debug("Copy/Move operation from '%s' to '%s'", source_path, dest_path)
|
||||
# Raises an EnvironmentError if there's a problem
|
||||
if copy:
|
||||
smart_copy(source_path, dest_path)
|
||||
|
@ -192,6 +192,10 @@ class Folder(File):
|
||||
self._subfolders = [Folder(p) for p in subfolders]
|
||||
return self._subfolders
|
||||
|
||||
@classmethod
|
||||
def can_handle(cls, path):
|
||||
return not io.islink(path) and io.isdir(path)
|
||||
|
||||
|
||||
def get_file(path, fileclasses=[File]):
|
||||
for fileclass in fileclasses:
|
||||
|
@ -91,8 +91,8 @@ class TestCaseDupeGuru:
|
||||
dgapp.copy_or_move(f, True, 'some_destination', 0)
|
||||
eq_(1, len(hscommon.conflict.smart_copy.calls))
|
||||
call = hscommon.conflict.smart_copy.calls[0]
|
||||
eq_('some_destination', call['dest_path'])
|
||||
eq_(f.path, call['source_path'])
|
||||
eq_(call['dest_path'], op.join('some_destination', 'foo'))
|
||||
eq_(call['source_path'], f.path)
|
||||
|
||||
def test_copy_or_move_clean_empty_dirs(self, tmpdir, monkeypatch):
|
||||
tmppath = Path(str(tmpdir))
|
||||
|
Loading…
x
Reference in New Issue
Block a user