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
5 changes: 4 additions & 1 deletion drive_utils/drive_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def upload_file_to_drive(folder_id, file_path, file_name):

# checking if files need updating

# prepare the file metadata and the media upload object
# prepare the file metadata and the media upload object
file_metadata = {'name': file_name, 'parents': [folder_id]}
media = MediaFileUpload(file_path, mimetype='application/octet-stream', resumable=True)
Expand All @@ -120,11 +121,13 @@ def upload_file_to_drive(folder_id, file_path, file_name):
if existing_files:
# if file exists, update it
file_id = existing_files[0]['id']
# For updates, we cannot include 'parents' field
update_metadata = {'name': file_name}
try:
# Update the existing file with the new content
file = service.files().update(
fileId=file_id,
body=file_metadata,
body=update_metadata,
media_body=media,
fields='id',
supportsAllDrives=True
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
os.makedirs(OUTPUT_DIR, exist_ok=True)

# Google Drive Shared Folder IDs (from env)
DRIVE_FOLDER_ID = os.getenv("DRIVE_FOLDER_ID")
DRIVE_LOG_FOLDER_ID = os.getenv("DRIVE_LOG_FOLDER_ID")
DRIVE_FOLDER_ID = os.getenv("DRIVE_FOLDER_ID", "").strip()
DRIVE_LOG_FOLDER_ID = os.getenv("DRIVE_LOG_FOLDER_ID", "").strip()

if not DRIVE_FOLDER_ID or not DRIVE_LOG_FOLDER_ID:
raise RuntimeError("Missing required Google Drive folder IDs")
Expand Down