Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline CRUD: first create folder #59

Open
tobiasKaminsky opened this issue Aug 7, 2024 · 1 comment
Open

Offline CRUD: first create folder #59

tobiasKaminsky opened this issue Aug 7, 2024 · 1 comment
Assignees

Comments

@tobiasKaminsky
Copy link
Member

tobiasKaminsky commented Aug 7, 2024

  • detect device being offline
    • with ping interval of 5s to /200 endpoint
    • when operation fails
  • store operations (e.g. delete folder, create folder)
  • show them file list as "pending to be created"
  • detect being online again
  • executing pending operation
@tobiasKaminsky tobiasKaminsky changed the title Offline CRUD Offline CRUD: first create folder Aug 7, 2024
@alperozturk96
Copy link

alperozturk96 commented Aug 27, 2024

Key Implementation Details:

  • OfflineOperationEntity Data Class:

    • This class is used for managing offline operations in the database.
    • Attributes:
      • id: Unique identifier for the operation (nullable).
      • parentOCFileId: ID of the parent directory (nullable).
      • parentPath: Full path of the parent directory (nullable).
      • type: Type of offline operation (uses the OfflineOperationType enum).
      • path: Path where the operation will be executed.
      • filename: Name of the folder or file involved in the operation.
      • createdAt: Timestamp of when the operation was created.
  • OfflineOperationType Enum:

    • Currently, it only has one value: CreateFolder.
    • As more offline operations are implemented, this enum will help distinguish between different types, determining the appropriate execution logic.
  • Handling parentPath:

    • parentPath is critical as it represents the full path of the parent directory.
    • Execution Constraint:
      • If an operation in the queue has a null parentPath, it cannot be executed because a folder cannot be created in a non-existent directory. The parent directory must exist before any sub-directory operations can be performed.

OfflineOperationsWorker Class:

  • Purpose:

    • This class is responsible for executing background jobs related to pending offline operations.
  • Triggers:

    1. Manual Trigger Depends On Internet Connectivity Status:
      • When the device reconnects to the internet and the server is reachable, the app triggers the worker to execute pending operations.
    2. Periodic Trigger:
      • The worker is also registered to trigger automatically every 5 minutes to ensure that operations are retried periodically without relying solely on internet connection toggling.
  • Execution Logic:

    • The worker checks for internet connectivity, server availability, and the presence of pending operations in the database. If all conditions are met, the worker begins processing the queue.

UI Considerations for Offline Operations:

  • Supported Actions:

    • Rename: Users can rename offline operation filenames.
    • Delete: Users can delete offline operations.
  • Unsupported Actions:

    • Move or Copy:
    • Set as Favorite:
    • Encrypt/Decrypt:
    • Download:
  • Operation Updates:

    • If a user deletes or renames an offline operation, subsequent operations in the queue that depend on it must be updated accordingly. After server operation completed we can update the DB then DB will have most updated values no need to do it beforehand.
    • Examples:
      • If the root directory for an operation is deleted, the following operations should not be executed.
      • If the root directory’s name is changed, subsequent operations must be updated to reflect the new name to ensure successful execution.

Handling Duplicate Folder Creation:

  • Conflict Resolution:
    • If both the server and the user create the same folder while offline, the app provides options to resolve conflicts by choosing between the local, remote, or both versions of the folder.
    • Naming Strategy:
      • The conflict is resolved by appending the current date to the folder’s name for clear differentiation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ☑️ Done
Development

No branches or pull requests

3 participants