Skip to content

Conversation

@bvisible
Copy link

Summary

Fixes TypeError when deleting or restoring files at root level (files with no parent folder).

Problem

Files at root level have parent_entity = NULL. When trying to delete/restore them via remove_or_restore, the code attempts to update the parent folder's file_size:

folder_size = frappe.db.get_value("Drive File", doc.parent_entity, "file_size")
frappe.db.set_value(..., folder_size + doc.file_size * ...)

This fails with:

TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Solution

  • Added check if doc.parent_entity: before updating parent folder size
  • Added or 0 fallback for safety in case parent exists but has NULL file_size

Testing

  • Tested on production instance with files at root level
  • Verified delete and restore operations work correctly

Files at root level have no parent_entity, causing TypeError when
trying to update parent folder size. Added check to skip parent
size update for root level files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant