mirror of
https://github.com/tcsenpai/pensieve.git
synced 2025-06-06 19:25:24 +00:00
feat: switch to absolute path
This commit is contained in:
parent
cd3672afe7
commit
9e4e23469f
@ -110,29 +110,26 @@ def scan(library_id: int):
|
|||||||
)
|
)
|
||||||
pbar.update(1)
|
pbar.update(1)
|
||||||
file_path = Path(root) / file
|
file_path = Path(root) / file
|
||||||
relative_file_path = file_path.relative_to(
|
absolute_file_path = file_path.resolve() # Get absolute path
|
||||||
folder_path
|
scanned_files.add(str(absolute_file_path)) # Add to scanned files set
|
||||||
) # Get relative path
|
|
||||||
scanned_files.add(str(relative_file_path)) # Add to scanned files set
|
|
||||||
file_stat = file_path.stat()
|
file_stat = file_path.stat()
|
||||||
file_type = (
|
file_type = (
|
||||||
mimetypes.guess_type(file_path)[0] or "application/octet-stream"
|
mimetypes.guess_type(file_path)[0] or "application/octet-stream"
|
||||||
)
|
)
|
||||||
new_entity = {
|
new_entity = {
|
||||||
"filename": file_path.name,
|
"filename": file_path.name,
|
||||||
"filepath": str(relative_file_path), # Save relative path
|
"filepath": str(absolute_file_path), # Save absolute path
|
||||||
"size": file_stat.st_size,
|
"size": file_stat.st_size,
|
||||||
"file_created_at": format_timestamp(file_stat.st_ctime),
|
"file_created_at": format_timestamp(file_stat.st_ctime),
|
||||||
"file_last_modified_at": format_timestamp(file_stat.st_mtime),
|
"file_last_modified_at": format_timestamp(file_stat.st_mtime),
|
||||||
"file_type": file_type,
|
"file_type": file_type,
|
||||||
"folder_id": folder["id"],
|
"folder_id": folder["id"],
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if the entity already exists
|
# Check if the entity already exists
|
||||||
get_response = httpx.get(
|
get_response = httpx.get(
|
||||||
f"{BASE_URL}/libraries/{library_id}/entities/by-filepath",
|
f"{BASE_URL}/libraries/{library_id}/entities/by-filepath",
|
||||||
params={
|
params={
|
||||||
"filepath": str(relative_file_path)
|
"filepath": str(absolute_file_path)
|
||||||
}, # Use relative path
|
}, # Use relative path
|
||||||
)
|
)
|
||||||
if get_response.status_code == 200:
|
if get_response.status_code == 200:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user