Permalink
Browse files

Include path separator and absolute path when checking if destination…

… is a child of the source. Fixes gh-287
  • Loading branch information...
jmathai committed Dec 2, 2018
1 parent 3f96e09 commit 65aa5cecd05b3f297acdc995ce5b38324ff058df
Showing with 3 additions and 3 deletions.
  1. +1 −1 elodie.py
  2. +2 −2 elodie/tests/elodie_test.py
@@ -46,7 +46,7 @@ def import_file(_file, destination, album_from_folder, trash, allow_duplicates):
(_file, _file))
return
# Check if the source, _file, is a child folder within destination
elif destination.startswith(os.path.dirname(_file)):
elif destination.startswith(os.path.abspath(os.path.dirname(_file))+os.sep):
print('{"source": "%s", "destination": "%s", "error_msg": "Source cannot be in destination"}' % (_file, destination))
return

@@ -240,8 +240,8 @@ def test_import_destination_in_source():
folder_destination = '{}/destination'.format(folder)
os.mkdir(folder_destination)

origin = '%s/video.mov' % folder
shutil.copyfile(helper.get_file('video.mov'), origin)
origin = '%s/plain.jpg' % folder
shutil.copyfile(helper.get_file('plain.jpg'), origin)

helper.reset_dbs()
dest_path = elodie.import_file(origin, folder_destination, False, False, False)

0 comments on commit 65aa5ce

Please sign in to comment.