Skip to content

Replace the ad-hoc Node __eq__ in share dedup with a stable node ID #12

Description

@devangb3

ShareManager.receive uses node in self.share_list[from_username], which relies on Node.__eq__ comparing name/is_folder/file_obj. Two different files named "report.pdf" from the same sender with different CIDs will be treated as identical because Node.__eq__ doesn't actually check child structure on folders (children dict isn't compared). A stable per-node UUID fixes multiple bugs at once.

Current state:
Node.__eq__ in node.py compares (name, is_folder, file_obj); children and subtree are not part of equality. File.__eq__ compares all four fields including creation_date, so it's narrower than expected.

Proposed implementation:

  1. Add node.id = str(uuid.uuid4()) on creation, persisted in JSON.
  2. ShareManager.receive dedups by id.
  3. ShareManager.delete takes an id instead of comparing by (name, is_folder).
  4. Migration: on load, backfill missing IDs.

Files likely affected:

  • backend/node.py
  • backend/share_manager.py
  • backend/delete_service.py
  • Tests.

Acceptance criteria:

  • Two distinct files with the same name from the same sender are both kept in the share list.
  • Deleting one removes exactly one.
  • Existing serialized trees continue to load.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions