address feedback
This commit is contained in:
@@ -614,7 +614,6 @@ async def update_drive_file(
|
||||
"""
|
||||
logger.info(f"[update_drive_file] Updating file {file_id} for {user_google_email}")
|
||||
|
||||
try:
|
||||
# First, get current file info for reference
|
||||
current_file = await asyncio.to_thread(
|
||||
service.files().get(
|
||||
@@ -673,24 +672,31 @@ async def update_drive_file(
|
||||
if name is not None and name != current_file.get('name'):
|
||||
changes.append(f" • Name: '{current_file.get('name')}' → '{name}'")
|
||||
if description is not None:
|
||||
old_desc = current_file.get('description', '(empty)')
|
||||
new_desc = description if description else '(empty)'
|
||||
if old_desc != new_desc:
|
||||
changes.append(f" • Description: {old_desc} → {new_desc}")
|
||||
old_desc_value = current_file.get('description')
|
||||
new_desc_value = description
|
||||
should_report_change = (old_desc_value or '') != (new_desc_value or '')
|
||||
if should_report_change:
|
||||
old_desc_display = old_desc_value if old_desc_value not in (None, '') else '(empty)'
|
||||
new_desc_display = new_desc_value if new_desc_value not in (None, '') else '(empty)'
|
||||
changes.append(f" • Description: {old_desc_display} → {new_desc_display}")
|
||||
if add_parents:
|
||||
changes.append(f" • Added to folder(s): {add_parents}")
|
||||
if remove_parents:
|
||||
changes.append(f" • Removed from folder(s): {remove_parents}")
|
||||
if starred is not None:
|
||||
current_starred = current_file.get('starred')
|
||||
if starred is not None and starred != current_starred:
|
||||
star_status = "starred" if starred else "unstarred"
|
||||
changes.append(f" • File {star_status}")
|
||||
if trashed is not None:
|
||||
current_trashed = current_file.get('trashed')
|
||||
if trashed is not None and trashed != current_trashed:
|
||||
trash_status = "moved to trash" if trashed else "restored from trash"
|
||||
changes.append(f" • File {trash_status}")
|
||||
if writers_can_share is not None:
|
||||
current_writers_can_share = current_file.get('writersCanShare')
|
||||
if writers_can_share is not None and writers_can_share != current_writers_can_share:
|
||||
share_status = "can" if writers_can_share else "cannot"
|
||||
changes.append(f" • Writers {share_status} share the file")
|
||||
if copy_requires_writer_permission is not None:
|
||||
current_copy_requires_writer_permission = current_file.get('copyRequiresWriterPermission')
|
||||
if copy_requires_writer_permission is not None and copy_requires_writer_permission != current_copy_requires_writer_permission:
|
||||
copy_status = "requires" if copy_requires_writer_permission else "doesn't require"
|
||||
changes.append(f" • Copying {copy_status} writer permission")
|
||||
if properties:
|
||||
@@ -707,7 +713,3 @@ async def update_drive_file(
|
||||
output_parts.append(f"View file: {updated_file.get('webViewLink', '#')}")
|
||||
|
||||
return "\n".join(output_parts)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error updating file: {e}")
|
||||
return f"❌ Error updating file: {e}"
|
||||
|
||||
Reference in New Issue
Block a user