Merge pull request #8 from makermelissa/master

Fix copy issue when destination is a directory
This commit is contained in:
Melissa LeBlanc-Williams 2021-01-26 13:10:17 -08:00 committed by GitHub
commit 695fd5e69f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -339,6 +339,8 @@ class Shell:
source = self.path(source)
destination = self.path(destination)
if os.path.exists(source):
if not os.path.isdir(source) and os.path.isdir(destination):
destination += os.sep + os.path.basename(source)
shutil.move(source, destination)
def copy(self, source, destination):
@ -351,7 +353,9 @@ class Shell:
if os.path.isdir(source):
shutil.copytree(source, destination)
else:
shutil.copyfile(source, destination)
if os.path.isdir(destination):
destination += os.sep + os.path.basename(source)
shutil.copy(source, destination)
def remove(self, location):
"""