Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions jupyter_drives/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,27 @@ async def presigned_link(self, drive_name, path):
}
return response

async def check_file(self, drive_name, path):
"""Check if an object already exists within a drive.

Args:
drive_name: name of drive where object exists
path: path where content is located
"""
# eliminate leading and trailing backslashes
path = path.strip('/')
check = await self._file_system._exists(drive_name + '/' + path)
if check == False:
# check if we are dealing with a directory
check = await self._file_system._exists(drive_name + '/' + path + EMPTY_DIR_SUFFIX)
if check == False:
raise tornado.web.HTTPError(
status_code= httpx.codes.NOT_FOUND,
reason="Object does not already exist within drive.",
)

return

async def _get_drive_location(self, drive_name):
"""Helping function for getting drive region.

Expand Down
9 changes: 6 additions & 3 deletions src/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ export const countObjectNameAppearances = async (
path: string,
originalName: string
): Promise<number> => {
let counter: number = 0;
let dirCount: { [fileName: string]: number } = {};
path = path.substring(0, path.lastIndexOf('/'));

const response = await requestAPI<any>(
Expand All @@ -489,11 +489,14 @@ export const countObjectNameAppearances = async (
if (
fileName.substring(0, originalName.length + 1).includes(originalName)
) {
counter += 1;
dirCount[fileName] = 1;
}
});
}

const counter = Object.values(dirCount).reduce(
(sum, count) => sum + count,
0
);
return counter;
};

Expand Down
Loading