@@ -226,7 +226,7 @@ def _base_model(self, path):
226
226
227
227
four_o_four = "file or directory does not exist: %r" % path
228
228
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 ) :
230
230
self .log .info ("Refusing to serve hidden file or directory %r, via 404 Error" , os_path )
231
231
raise web .HTTPError (404 , four_o_four )
232
232
@@ -278,7 +278,7 @@ def _dir_model(self, path, content=True):
278
278
279
279
if not os .path .isdir (os_path ):
280
280
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 ) :
282
282
self .log .info ("Refusing to serve hidden directory %r, via 404 Error" , os_path )
283
283
raise web .HTTPError (404 , four_o_four )
284
284
@@ -414,7 +414,7 @@ def get(self, path, content=True, type=None, format=None):
414
414
if not self .exists (path ):
415
415
raise web .HTTPError (404 , four_o_four )
416
416
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 ) :
418
418
self .log .info ("Refusing to serve hidden file or directory %r, via 404 Error" , os_path )
419
419
raise web .HTTPError (404 , four_o_four )
420
420
@@ -437,7 +437,7 @@ def get(self, path, content=True, type=None, format=None):
437
437
438
438
def _save_directory (self , os_path , model , path = "" ):
439
439
"""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 ) :
441
441
raise web .HTTPError (400 , "Cannot create directory %r" % os_path )
442
442
if not os .path .exists (os_path ):
443
443
with self .perm_to_403 ():
@@ -460,7 +460,7 @@ def save(self, model, path=""):
460
460
461
461
os_path = self ._get_os_path (path )
462
462
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 ) :
464
464
raise web .HTTPError (400 , f"Cannot create file or directory { os_path !r} " )
465
465
466
466
self .log .debug ("Saving %s" , os_path )
@@ -506,7 +506,7 @@ def delete_file(self, path):
506
506
os_path = self ._get_os_path (path )
507
507
rm = os .unlink
508
508
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 ) :
510
510
raise web .HTTPError (400 , f"Cannot delete file or directory { os_path !r} " )
511
511
512
512
four_o_four = "file or directory does not exist: %r" % path
@@ -576,9 +576,9 @@ def rename_file(self, old_path, new_path):
576
576
new_os_path = self ._get_os_path (new_path )
577
577
old_os_path = self ._get_os_path (old_path )
578
578
579
- if (
579
+ if not self . allow_hidden and (
580
580
is_hidden (old_os_path , self .root_dir ) or is_hidden (new_os_path , self .root_dir )
581
- ) and not self . allow_hidden :
581
+ ):
582
582
raise web .HTTPError (400 , f"Cannot rename file or directory { old_os_path !r} " )
583
583
584
584
# Should we proceed with the move?
@@ -741,7 +741,7 @@ async def _dir_model(self, path, content=True):
741
741
742
742
if not os .path .isdir (os_path ):
743
743
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 ) :
745
745
self .log .info ("Refusing to serve hidden directory %r, via 404 Error" , os_path )
746
746
raise web .HTTPError (404 , four_o_four )
747
747
@@ -896,7 +896,7 @@ async def get(self, path, content=True, type=None, format=None):
896
896
897
897
async def _save_directory (self , os_path , model , path = "" ):
898
898
"""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 ) :
900
900
raise web .HTTPError (400 , "Cannot create hidden directory %r" % os_path )
901
901
if not os .path .exists (os_path ):
902
902
with self .perm_to_403 ():
@@ -961,7 +961,7 @@ async def delete_file(self, path):
961
961
os_path = self ._get_os_path (path )
962
962
rm = os .unlink
963
963
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 ) :
965
965
raise web .HTTPError (400 , f"Cannot delete file or directory { os_path !r} " )
966
966
967
967
if not os .path .exists (os_path ):
@@ -1035,9 +1035,9 @@ async def rename_file(self, old_path, new_path):
1035
1035
new_os_path = self ._get_os_path (new_path )
1036
1036
old_os_path = self ._get_os_path (old_path )
1037
1037
1038
- if (
1038
+ if not self . allow_hidden and (
1039
1039
is_hidden (old_os_path , self .root_dir ) or is_hidden (new_os_path , self .root_dir )
1040
- ) and not self . allow_hidden :
1040
+ ):
1041
1041
raise web .HTTPError (400 , f"Cannot rename file or directory { old_os_path !r} " )
1042
1042
1043
1043
# Should we proceed with the move?
0 commit comments