@@ -208,28 +208,23 @@ async def post(self, path=""):
208
208
raise web .HTTPError (400 , "Cannot POST to files, use PUT instead." )
209
209
210
210
model = self .get_json_body ()
211
- copy_from = model .get ("copy_from" )
212
- if (
213
- copy_from
214
- and (
215
- await ensure_async (cm .is_hidden (path ))
216
- or await ensure_async (cm .is_hidden (copy_from ))
217
- )
218
- and not cm .allow_hidden
219
- ):
220
- raise web .HTTPError (400 , f"Cannot copy file or directory { path !r} " )
221
-
222
- if model is not None :
211
+ if model :
223
212
copy_from = model .get ("copy_from" )
213
+ if copy_from :
214
+ if not cm .allow_hidden and (
215
+ await ensure_async (cm .is_hidden (path ))
216
+ or await ensure_async (cm .is_hidden (copy_from ))
217
+ ):
218
+ raise web .HTTPError (400 , f"Cannot copy file or directory { path !r} " )
219
+ else :
220
+ await self ._copy (copy_from , path )
221
+
224
222
ext = model .get ("ext" , "" )
225
223
type = model .get ("type" , "" )
226
224
if type not in {None , "" , "directory" , "file" , "notebook" }:
227
225
# fall back to file if unknown type
228
226
type = "file"
229
- if copy_from :
230
- await self ._copy (copy_from , path )
231
- else :
232
- await self ._new_untitled (path , type = type , ext = ext )
227
+ await self ._new_untitled (path , type = type , ext = ext )
233
228
else :
234
229
await self ._new_untitled (path )
235
230
0 commit comments