reporter
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import ctypes
|
||||
import time
|
||||
|
||||
from blake3 import blake3
|
||||
|
||||
@@ -17,6 +18,25 @@ def is_cloud_placeholder(path: str) -> bool:
|
||||
return bool(attrs & _CLOUD_MASK)
|
||||
|
||||
|
||||
def hydrate_file(path: str, timeout: int = 120, poll: int = 3) -> bool:
|
||||
"""
|
||||
Přinutí Dropbox stáhnout cloud placeholder otevřením souboru.
|
||||
Čeká max timeout sekund. Vrátí True pokud se soubor stáhl.
|
||||
"""
|
||||
try:
|
||||
with open(path, "rb") as f:
|
||||
f.read(1)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
deadline = time.time() + timeout
|
||||
while time.time() < deadline:
|
||||
if not is_cloud_placeholder(path):
|
||||
return True
|
||||
time.sleep(poll)
|
||||
return False
|
||||
|
||||
|
||||
def blake3_file(path, chunk_size=1024 * 1024):
|
||||
"""Spočítá BLAKE3 hash souboru po blocích (bez načtení do paměti)."""
|
||||
h = blake3()
|
||||
|
||||
Reference in New Issue
Block a user