feat: implement Google Drive integration and enhance documentation for new features
This commit is contained in:
+5
-33
@@ -1,35 +1,7 @@
|
||||
# app/utils.py
|
||||
import hashlib
|
||||
from app.database import SessionLocal
|
||||
from app.models import ProcessingLog
|
||||
# This file is deprecated. Functions have been moved to the utils package.
|
||||
# To avoid breaking existing imports, we'll import and re-export the functions
|
||||
from app.utils.file_operations import hash_file
|
||||
from app.utils.logging import log_task_progress
|
||||
|
||||
def hash_file(filepath, chunk_size=65536):
|
||||
"""
|
||||
Returns the SHA-256 hash of the file at 'filepath'.
|
||||
Reads the file in chunks to handle large files efficiently.
|
||||
"""
|
||||
sha256 = hashlib.sha256()
|
||||
with open(filepath, "rb") as f:
|
||||
while True:
|
||||
data = f.read(chunk_size)
|
||||
if not data:
|
||||
break
|
||||
sha256.update(data)
|
||||
return sha256.hexdigest()
|
||||
|
||||
|
||||
|
||||
def log_task_progress(task_id, step_name, status, message=None, file_id=None):
|
||||
"""
|
||||
Logs the progress of a Celery task to the database.
|
||||
"""
|
||||
with SessionLocal() as db:
|
||||
log_entry = ProcessingLog(
|
||||
task_id=task_id,
|
||||
step_name=step_name,
|
||||
status=status,
|
||||
message=message,
|
||||
file_id=file_id,
|
||||
)
|
||||
db.add(log_entry)
|
||||
db.commit()
|
||||
# These functions are now available directly from the app.utils package
|
||||
|
||||
Reference in New Issue
Block a user