File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -461,6 +461,10 @@ def copydir(
461461
462462 """
463463 with self ._lock :
464+ _src_path = self .validatepath (src_path )
465+ _dst_path = self .validatepath (dst_path )
466+ if isbase (_src_path , _dst_path ):
467+ raise errors .IllegalDestination (dst_path )
464468 if not create and not self .exists (dst_path ):
465469 raise errors .ResourceNotFound (dst_path )
466470 if not self .getinfo (src_path ).is_dir :
Original file line number Diff line number Diff line change @@ -1874,13 +1874,12 @@ def test_copydir_onto_itself(self):
18741874 self .assert_text ("folder/sub/file2.txt" , "Hello2" )
18751875
18761876 def test_copydir_into_its_own_subfolder (self ):
1877- # folder = self.fs.makedir("folder")
1878- # folder.writetext("file1.txt", "Hello1")
1879- # sub = folder.makedir("sub")
1880- # sub.writetext("file2.txt", "Hello2")
1881- # with self.assertRaises(errors.IllegalDestination):
1882- # self.fs.copydir("folder", "folder/sub/")
1883- pass
1877+ folder = self .fs .makedir ("folder" )
1878+ folder .writetext ("file1.txt" , "Hello1" )
1879+ sub = folder .makedir ("sub" )
1880+ sub .writetext ("file2.txt" , "Hello2" )
1881+ with self .assertRaises (errors .IllegalDestination ):
1882+ self .fs .copydir ("folder" , "folder/sub/" )
18841883
18851884 def test_movedir (self ):
18861885 self .fs .makedirs ("foo/bar/baz/egg" )
You can’t perform that action at this time.
0 commit comments