Skip to content

Commit d7562eb

Browse files
committed
iterate on check object functionality
1 parent 76516be commit d7562eb

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

jupyter_drives/manager.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -387,19 +387,17 @@ async def check_file(self, drive_name, path):
387387
drive_name: name of drive where object exists
388388
path: path where content is located
389389
"""
390-
result = False
391390
try:
392391
# eliminate leading and trailing backslashes
393392
path = path.strip('/')
394393
await obs.head_async(self._content_managers[drive_name], path)
395-
result = True
396394
except Exception:
397-
pass
395+
raise tornado.web.HTTPError(
396+
status_code= httpx.codes.NOT_FOUND,
397+
reason="Object does not already exist within drive.",
398+
)
398399

399-
response = {
400-
result: result
401-
}
402-
return response
400+
return
403401

404402
async def copy_file(self, drive_name, path, to_path):
405403
"""Save file with new content.

src/requests.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,7 @@ export async function checkObject(
431431
path: string;
432432
}
433433
) {
434-
const response = await requestAPI<any>(
435-
'drives/' + driveName + '/' + options.path,
436-
'HEAD'
437-
);
438-
439-
return response.result;
434+
await requestAPI<any>('drives/' + driveName + '/' + options.path, 'HEAD');
440435
}
441436

442437
/**
@@ -454,9 +449,10 @@ export const countObjectNameAppearances = async (
454449
originalName: string
455450
): Promise<number> => {
456451
let counter: number = 0;
452+
path = path.substring(0, path.lastIndexOf('/'));
457453

458454
const response = await requestAPI<any>(
459-
'drives/' + driveName + '/' + path.substring(0, path.lastIndexOf('/')),
455+
'drives/' + driveName + '/' + path,
460456
'GET'
461457
);
462458

0 commit comments

Comments
 (0)