@@ -226,7 +226,7 @@ def _base_model(self, path):
226226
227227 four_o_four = "file or directory does not exist: %r" % path
228228
229- if is_hidden ( os_path , self .root_dir ) and not self .allow_hidden :
229+ if not self .allow_hidden and is_hidden ( os_path , self .root_dir ) :
230230 self .log .info ("Refusing to serve hidden file or directory %r, via 404 Error" , os_path )
231231 raise web .HTTPError (404 , four_o_four )
232232
@@ -278,7 +278,7 @@ def _dir_model(self, path, content=True):
278278
279279 if not os .path .isdir (os_path ):
280280 raise web .HTTPError (404 , four_o_four )
281- elif is_hidden ( os_path , self .root_dir ) and not self .allow_hidden :
281+ elif not self .allow_hidden and is_hidden ( os_path , self .root_dir ) :
282282 self .log .info ("Refusing to serve hidden directory %r, via 404 Error" , os_path )
283283 raise web .HTTPError (404 , four_o_four )
284284
@@ -414,7 +414,7 @@ def get(self, path, content=True, type=None, format=None):
414414 if not self .exists (path ):
415415 raise web .HTTPError (404 , four_o_four )
416416
417- if is_hidden ( os_path , self .root_dir ) and not self .allow_hidden :
417+ if not self .allow_hidden and is_hidden ( os_path , self .root_dir ) :
418418 self .log .info ("Refusing to serve hidden file or directory %r, via 404 Error" , os_path )
419419 raise web .HTTPError (404 , four_o_four )
420420
@@ -437,7 +437,7 @@ def get(self, path, content=True, type=None, format=None):
437437
438438 def _save_directory (self , os_path , model , path = "" ):
439439 """create a directory"""
440- if is_hidden ( os_path , self .root_dir ) and not self .allow_hidden :
440+ if not self .allow_hidden and is_hidden ( os_path , self .root_dir ) :
441441 raise web .HTTPError (400 , "Cannot create directory %r" % os_path )
442442 if not os .path .exists (os_path ):
443443 with self .perm_to_403 ():
@@ -460,7 +460,7 @@ def save(self, model, path=""):
460460
461461 os_path = self ._get_os_path (path )
462462
463- if is_hidden ( os_path , self .root_dir ) and not self .allow_hidden :
463+ if not self .allow_hidden and is_hidden ( os_path , self .root_dir ) :
464464 raise web .HTTPError (400 , f"Cannot create file or directory { os_path !r} " )
465465
466466 self .log .debug ("Saving %s" , os_path )
@@ -506,7 +506,7 @@ def delete_file(self, path):
506506 os_path = self ._get_os_path (path )
507507 rm = os .unlink
508508
509- if is_hidden ( os_path , self .root_dir ) and not self .allow_hidden :
509+ if not self .allow_hidden and is_hidden ( os_path , self .root_dir ) :
510510 raise web .HTTPError (400 , f"Cannot delete file or directory { os_path !r} " )
511511
512512 four_o_four = "file or directory does not exist: %r" % path
@@ -576,9 +576,9 @@ def rename_file(self, old_path, new_path):
576576 new_os_path = self ._get_os_path (new_path )
577577 old_os_path = self ._get_os_path (old_path )
578578
579- if (
579+ if not self . allow_hidden and (
580580 is_hidden (old_os_path , self .root_dir ) or is_hidden (new_os_path , self .root_dir )
581- ) and not self . allow_hidden :
581+ ):
582582 raise web .HTTPError (400 , f"Cannot rename file or directory { old_os_path !r} " )
583583
584584 # Should we proceed with the move?
@@ -741,7 +741,7 @@ async def _dir_model(self, path, content=True):
741741
742742 if not os .path .isdir (os_path ):
743743 raise web .HTTPError (404 , four_o_four )
744- elif is_hidden ( os_path , self .root_dir ) and not self .allow_hidden :
744+ elif not self .allow_hidden and is_hidden ( os_path , self .root_dir ) :
745745 self .log .info ("Refusing to serve hidden directory %r, via 404 Error" , os_path )
746746 raise web .HTTPError (404 , four_o_four )
747747
@@ -896,7 +896,7 @@ async def get(self, path, content=True, type=None, format=None):
896896
897897 async def _save_directory (self , os_path , model , path = "" ):
898898 """create a directory"""
899- if is_hidden ( os_path , self .root_dir ) and not self .allow_hidden :
899+ if not self .allow_hidden and is_hidden ( os_path , self .root_dir ) :
900900 raise web .HTTPError (400 , "Cannot create hidden directory %r" % os_path )
901901 if not os .path .exists (os_path ):
902902 with self .perm_to_403 ():
@@ -961,7 +961,7 @@ async def delete_file(self, path):
961961 os_path = self ._get_os_path (path )
962962 rm = os .unlink
963963
964- if is_hidden ( os_path , self .root_dir ) and not self .allow_hidden :
964+ if not self .allow_hidden and is_hidden ( os_path , self .root_dir ) :
965965 raise web .HTTPError (400 , f"Cannot delete file or directory { os_path !r} " )
966966
967967 if not os .path .exists (os_path ):
@@ -1035,9 +1035,9 @@ async def rename_file(self, old_path, new_path):
10351035 new_os_path = self ._get_os_path (new_path )
10361036 old_os_path = self ._get_os_path (old_path )
10371037
1038- if (
1038+ if not self . allow_hidden and (
10391039 is_hidden (old_os_path , self .root_dir ) or is_hidden (new_os_path , self .root_dir )
1040- ) and not self . allow_hidden :
1040+ ):
10411041 raise web .HTTPError (400 , f"Cannot rename file or directory { old_os_path !r} " )
10421042
10431043 # Should we proceed with the move?
0 commit comments