mirror of
https://github.com/tcsenpai/pensieve.git
synced 2025-06-09 04:35:26 +00:00
feat(scan): give the entity count when scan lib to delete entities
This commit is contained in:
parent
e7be69f0ef
commit
4a90d86c16
@ -269,6 +269,8 @@ def scan(
|
|||||||
# Check for deleted files
|
# Check for deleted files
|
||||||
limit = 200
|
limit = 200
|
||||||
offset = 0
|
offset = 0
|
||||||
|
total_files = float('inf') # We'll update this after the first request
|
||||||
|
with tqdm(total=total_files, desc="Checking for deleted files", unit="file") as pbar:
|
||||||
while True:
|
while True:
|
||||||
existing_files_response = httpx.get(
|
existing_files_response = httpx.get(
|
||||||
f"{BASE_URL}/libraries/{library_id}/folders/{folder['id']}/entities",
|
f"{BASE_URL}/libraries/{library_id}/folders/{folder['id']}/entities",
|
||||||
@ -285,6 +287,12 @@ def scan(
|
|||||||
if not existing_files:
|
if not existing_files:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# Update total if this is the first request
|
||||||
|
if offset == 0:
|
||||||
|
total_files = int(existing_files_response.headers.get('X-Total-Count', total_files))
|
||||||
|
pbar.total = total_files
|
||||||
|
pbar.refresh()
|
||||||
|
|
||||||
for existing_file in existing_files:
|
for existing_file in existing_files:
|
||||||
if existing_file["filepath"] not in scanned_files:
|
if existing_file["filepath"] not in scanned_files:
|
||||||
# File has been deleted
|
# File has been deleted
|
||||||
@ -300,6 +308,8 @@ def scan(
|
|||||||
tqdm.write(
|
tqdm.write(
|
||||||
f"Failed to delete file: {delete_response.status_code} - {delete_response.text}"
|
f"Failed to delete file: {delete_response.status_code} - {delete_response.text}"
|
||||||
)
|
)
|
||||||
|
pbar.update(1)
|
||||||
|
pbar.refresh()
|
||||||
|
|
||||||
offset += limit
|
offset += limit
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user