{ "issue": { "url": "https://api.github.com/repos/laurent22/joplin/issues/14537", "repository_url": "https://api.github.com/repos/laurent22/joplin", "labels_url": "https://api.github.com/repos/laurent22/joplin/issues/14537/labels{/name}", "comments_url": "https://api.github.com/repos/laurent22/joplin/issues/14537/comments", "events_url": "https://api.github.com/repos/laurent22/joplin/issues/14537/events", "html_url": "https://github.com/laurent22/joplin/pull/14537", "id": 4015500482, "node_id": "PR_kwDOBLftOs7HjDfL", "number": 14537, "title": "All: Resolves #9093: Delete .crypted files when the app starts", "user": { "login": "justin212407", "id": 143245796, "node_id": "U_kgDOCInB5A", "avatar_url": "https://avatars.githubusercontent.com/u/143245796?v=4", "gravatar_id": "", "url": "https://api.github.com/users/justin212407", "html_url": "https://github.com/justin212407", "followers_url": "https://api.github.com/users/justin212407/followers", "following_url": "https://api.github.com/users/justin212407/following{/other_user}", "gists_url": "https://api.github.com/users/justin212407/gists{/gist_id}", "starred_url": "https://api.github.com/users/justin212407/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/justin212407/subscriptions", "organizations_url": "https://api.github.com/users/justin212407/orgs", "repos_url": "https://api.github.com/users/justin212407/repos", "events_url": "https://api.github.com/users/justin212407/events{/privacy}", "received_events_url": "https://api.github.com/users/justin212407/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "labels": [ { "id": 519700741, "node_id": "MDU6TGFiZWw1MTk3MDA3NDE=", "url": "https://api.github.com/repos/laurent22/joplin/labels/bug", "name": "bug", "color": "cf353b", "default": true, "description": "It's a bug" }, { "id": 519700743, "node_id": "MDU6TGFiZWw1MTk3MDA3NDM=", "url": "https://api.github.com/repos/laurent22/joplin/labels/enhancement", "name": "enhancement", "color": "5ebeff", "default": true, "description": "Feature requests and code enhancements" }, { "id": 1366675015, "node_id": "MDU6TGFiZWwxMzY2Njc1MDE1", "url": "https://api.github.com/repos/laurent22/joplin/labels/sync", "name": "sync", "color": "91ca55", "default": false, "description": "sync related issue" } ], "state": "closed", "locked": false, "assignees": [], "milestone": null, "comments": 3, "created_at": "2026-03-03T09:00:45Z", "updated_at": "2026-03-03T11:17:03Z", "closed_at": "2026-03-03T11:16:49Z", "assignee": null, "author_association": "CONTRIBUTOR", "active_lock_reason": null, "draft": false, "pull_request": { "url": "https://api.github.com/repos/laurent22/joplin/pulls/14537", "html_url": "https://github.com/laurent22/joplin/pull/14537", "diff_url": "https://github.com/laurent22/joplin/pull/14537.diff", "patch_url": "https://github.com/laurent22/joplin/pull/14537.patch", "merged_at": null }, "body": "fixes #9093 \r\n\r\n### AI Disclosure:\r\nI used AI to understand the resource encryption/decryption flows. I also used AI to create a draft test to test the implementation.\r\n\r\n### Problem: \r\n- When `Resource.decrypt()` decrypts an encrypted blob, it first renames the downloaded file to .crypted before decrypting it into the final plaintext path. Similarly, Synchronizer creates temporary .crypted files during resource upload via `fullPathForSyncUpload()`.\r\n\r\n- However, neither code path reliably removes the .crypted file on success. If the app crashes, is force-quit, or sync is interrupted mid-operation, the .crypted temporary file remains in the resource directory indefinitely. Over time, these stale files accumulate, wasting disk space and cluttering the resources folder.\r\n\r\n### Fix:\r\nI implemented a three step cleanup to safely remove .crypted files:\r\n1. Inline cleanup after successful decrypt - When `Resource.decrypt()` completes successfully, immediately remove the temporary .crypted file.\r\n2. Inline cleanup after successful upload - When Synchronizer finishes uploading an encrypted blob, immediately remove the .crypted temp file.\r\n3. Startup maintenance sweep - Call `Resource.cleanupCryptedFiles()` during app startup to remove orphaned or stale .crypted files while preserving files still needed for pending decryption.\r\n\r\n### Testing:\r\nFor testing I created a draft test file to check whether the functionalities are properly implemented. All checks passed. All existing tests also pass.", "closed_by": { "login": "justin212407", "id": 143245796, "node_id": "U_kgDOCInB5A", "avatar_url": "https://avatars.githubusercontent.com/u/143245796?v=4", "gravatar_id": "", "url": "https://api.github.com/users/justin212407", "html_url": "https://github.com/justin212407", "followers_url": "https://api.github.com/users/justin212407/followers", "following_url": "https://api.github.com/users/justin212407/following{/other_user}", "gists_url": "https://api.github.com/users/justin212407/gists{/gist_id}", "starred_url": "https://api.github.com/users/justin212407/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/justin212407/subscriptions", "organizations_url": "https://api.github.com/users/justin212407/orgs", "repos_url": "https://api.github.com/users/justin212407/repos", "events_url": "https://api.github.com/users/justin212407/events{/privacy}", "received_events_url": "https://api.github.com/users/justin212407/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/14537/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "timeline_url": "https://api.github.com/repos/laurent22/joplin/issues/14537/timeline", "performed_via_github_app": null, "state_reason": null }, "comments": [ { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/3989617523", "html_url": "https://github.com/laurent22/joplin/pull/14537#issuecomment-3989617523", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/14537", "id": 3989617523, "node_id": "IC_kwDOBLftOs7tzLtz", "user": { "login": "github-actions[bot]", "id": 41898282, "node_id": "MDM6Qm90NDE4OTgyODI=", "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4", "gravatar_id": "", "url": "https://api.github.com/users/github-actions%5Bbot%5D", "html_url": "https://github.com/apps/github-actions", "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers", "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}", "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}", "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions", "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs", "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos", "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}", "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events", "type": "Bot", "user_view_type": "public", "site_admin": false }, "created_at": "2026-03-03T09:00:58Z", "updated_at": "2026-03-03T11:17:03Z", "body": "****CLA Assistant Lite bot**** All contributors have signed the CLA ✍️ ✅", "author_association": "CONTRIBUTOR", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/3989617523/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": { "id": 15368, "client_id": "Iv1.05c79e9ad1f6bdfa", "slug": "github-actions", "node_id": "MDM6QXBwMTUzNjg=", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/github", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "Organization", "user_view_type": "public", "site_admin": false }, "name": "GitHub Actions", "description": "Automate your workflow from idea to production", "external_url": "https://help.github.com/en/actions", "html_url": "https://github.com/apps/github-actions", "created_at": "2018-07-30T09:30:17Z", "updated_at": "2026-05-05T14:51:38Z", "permissions": { "actions": "write", "administration": "read", "artifact_metadata": "write", "attestations": "write", "checks": "write", "code_quality": "write", "contents": "write", "copilot_requests": "write", "deployments": "write", "discussions": "write", "issues": "write", "merge_queues": "write", "metadata": "read", "models": "read", "packages": "write", "pages": "write", "pull_requests": "write", "repository_hooks": "write", "repository_projects": "write", "security_events": "write", "statuses": "write", "vulnerability_alerts": "read" }, "events": [ "branch_protection_rule", "check_run", "check_suite", "create", "delete", "deployment", "deployment_status", "discussion", "discussion_comment", "fork", "gollum", "issues", "issue_comment", "label", "merge_group", "milestone", "page_build", "public", "pull_request", "pull_request_review", "pull_request_review_comment", "push", "registry_package", "release", "repository", "repository_dispatch", "status", "watch", "workflow_dispatch", "workflow_run" ] } }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/3989618932", "html_url": "https://github.com/laurent22/joplin/pull/14537#issuecomment-3989618932", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/14537", "id": 3989618932, "node_id": "IC_kwDOBLftOs7tzMD0", "user": { "login": "coderabbitai[bot]", "id": 136622811, "node_id": "BOT_kgDOCCSy2w", "avatar_url": "https://avatars.githubusercontent.com/in/347564?v=4", "gravatar_id": "", "url": "https://api.github.com/users/coderabbitai%5Bbot%5D", "html_url": "https://github.com/apps/coderabbitai", "followers_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/followers", "following_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/following{/other_user}", "gists_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/gists{/gist_id}", "starred_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/subscriptions", "organizations_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/orgs", "repos_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/repos", "events_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/events{/privacy}", "received_events_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/received_events", "type": "Bot", "user_view_type": "public", "site_admin": false }, "created_at": "2026-03-03T09:01:16Z", "updated_at": "2026-03-03T11:05:47Z", "body": "\n\n\n
\n📝 Walkthrough\n\n## Walkthrough\n\nStartup and runtime flows now remove leftover temporary `.crypted` files. A new Resource.cleanupCryptedFiles() is invoked during application startup and after decryption; decrypt and upload paths were changed to properly await moves and to remove temporary encrypted files only when appropriate.\n\n## Changes\n\n|Cohort / File(s)|Summary|\n|---|---|\n|**Startup Cleanup**
`packages/lib/BaseApplication.ts`|Calls `Resource.cleanupCryptedFiles()` after wiring the DecryptionWorker event handler and in the initial startup path to remove leftover `.crypted` files from previous sessions.|\n|**Decryption & Resource Cleanup**
`packages/lib/models/Resource.ts`|`decrypt` now awaits move of failed decrypt attempts, removes the encrypted `.crypted` file after successful decryption when appropriate, and adds `public static async cleanupCryptedFiles()` to scan the resources directory and delete stale `.crypted` files.|\n|**Upload Cleanup**
`packages/lib/Synchronizer.ts`|During UPLOAD, computes whether a blob was already encrypted and deletes the local temporary encrypted blob file only when the blob was freshly encrypted by the client.|\n\n## Sequence Diagram(s)\n\n```mermaid\nsequenceDiagram\n autonumber\n actor User\n participant App as BaseApplication\n participant Worker as DecryptionWorker\n participant ResourceModel as Resource\n participant FS as FileSystem\n\n User->>App: Start application\n App->>Worker: Wire decryption event handler\n App->>ResourceModel: Resource.cleanupCryptedFiles()\n ResourceModel->>FS: Scan resources dir for *.crypted\n FS-->>ResourceModel: List of .crypted files\n ResourceModel->>FS: Remove leftover .crypted files\n FS-->>ResourceModel: Removal results\n ResourceModel-->>App: Cleanup complete\n```\n\n
\n\n\n\n\n\n\n
\n🚥 Pre-merge checks | ✅ 6\n\n
\n✅ Passed checks (6 passed)\n\n| Check name | Status | Explanation |\n| :-----------------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Title check | ✅ Passed | The title accurately summarises the main change: deleting .crypted files at app startup, which is the primary objective of issue `#9093`. |\n| Description check | ✅ Passed | The description is directly related to the changeset, explaining the problem with accumulating .crypted files and detailing the three-step cleanup solution implemented. |\n| Linked Issues check | ✅ Passed | The implementation meets all requirements from `#9093`: inline cleanup after successful decrypt and upload operations, plus a startup maintenance sweep via Resource.cleanupCryptedFiles() that removes orphaned files whilst preserving those needed for pending decryption. |\n| Out of Scope Changes check | ✅ Passed | All changes are directly scoped to the issue objectives: Resource.decrypt() cleanup, Synchronizer upload cleanup, and the new Resource.cleanupCryptedFiles() startup maintenance method. |\n| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |\n| Pr Description Must Follow Guidelines | ✅ Passed | The pull request description includes all required sections: Problem statement describing .crypted file accumulation, Solution detailing the three-step cleanup strategy, and Testing confirming test creation and passing checks. |\n\n
\n\n✏️ Tip: You can configure your own custom pre-merge checks in the settings.\n\n
\n\n\n\n\n\n
\n✨ Finishing Touches\n\n
\n🧪 Generate unit tests (beta)\n\n- [ ] Create PR with unit tests\n- [ ] Post copyable unit tests in a comment\n\n
\n\n
\n\n\n\n\n\n---\n\nThanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=laurent22/joplin&utm_content=14537)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n
\n❤️ Share\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n
\n\nComment `@coderabbitai help` to get the list of available commands and usage tips.\n\n\n\n\n\n\n\n\n", "author_association": "CONTRIBUTOR", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/3989618932/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": { "id": 347564, "client_id": "Iv1.6aaafe4fe882736b", "slug": "coderabbitai", "node_id": "A_kwHOB96YWc4ABU2s", "owner": { "login": "coderabbitai", "id": 132028505, "node_id": "O_kgDOB96YWQ", "avatar_url": "https://avatars.githubusercontent.com/u/132028505?v=4", "gravatar_id": "", "url": "https://api.github.com/users/coderabbitai", "html_url": "https://github.com/coderabbitai", "followers_url": "https://api.github.com/users/coderabbitai/followers", "following_url": "https://api.github.com/users/coderabbitai/following{/other_user}", "gists_url": "https://api.github.com/users/coderabbitai/gists{/gist_id}", "starred_url": "https://api.github.com/users/coderabbitai/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/coderabbitai/subscriptions", "organizations_url": "https://api.github.com/users/coderabbitai/orgs", "repos_url": "https://api.github.com/users/coderabbitai/repos", "events_url": "https://api.github.com/users/coderabbitai/events{/privacy}", "received_events_url": "https://api.github.com/users/coderabbitai/received_events", "type": "Organization", "user_view_type": "public", "site_admin": false }, "name": "coderabbitai", "description": "# Transforming Code Reviews with AI\r\n\r\n## Features\r\n\r\n**Automated Reviews**: Continuous reviews of the pull requests including incremental commits. \r\n\r\n**Summarization**: Generates high-level summary and a technical walkthrough of the PR changes. \r\n\r\n**Line-by-line review**: Provides line-by-line suggestions committable with one click.\r\n\r\n**Codebase verification**: Verifies the impact on the overall codebase and identifies missing changes.\r\n\r\n**Insights into your code**: Ask any questions on your codebase within the pull request \r\n\r\n**Chat about your code** : Chat with the bot around your code. The more you chat, the smarter it gets.\r\n\r\n**Issue Validation**: Validates the PR against the linked issues and identifies other related issues \r\n\r\n\r\n\r\n", "external_url": "https://coderabbit.ai?utm_source=cr_app&utm_medium=github", "html_url": "https://github.com/apps/coderabbitai", "created_at": "2023-06-14T15:47:27Z", "updated_at": "2026-03-14T07:58:44Z", "permissions": { "actions": "read", "checks": "write", "contents": "write", "discussions": "read", "issues": "write", "members": "read", "metadata": "read", "pull_requests": "write", "statuses": "write" }, "events": [ "issues", "issue_comment", "label", "organization", "pull_request", "pull_request_review", "pull_request_review_comment", "pull_request_review_thread", "release", "repository" ] } }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/3989623739", "html_url": "https://github.com/laurent22/joplin/pull/14537#issuecomment-3989623739", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/14537", "id": 3989623739, "node_id": "IC_kwDOBLftOs7tzNO7", "user": { "login": "justin212407", "id": 143245796, "node_id": "U_kgDOCInB5A", "avatar_url": "https://avatars.githubusercontent.com/u/143245796?v=4", "gravatar_id": "", "url": "https://api.github.com/users/justin212407", "html_url": "https://github.com/justin212407", "followers_url": "https://api.github.com/users/justin212407/followers", "following_url": "https://api.github.com/users/justin212407/following{/other_user}", "gists_url": "https://api.github.com/users/justin212407/gists{/gist_id}", "starred_url": "https://api.github.com/users/justin212407/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/justin212407/subscriptions", "organizations_url": "https://api.github.com/users/justin212407/orgs", "repos_url": "https://api.github.com/users/justin212407/repos", "events_url": "https://api.github.com/users/justin212407/events{/privacy}", "received_events_url": "https://api.github.com/users/justin212407/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2026-03-03T09:02:21Z", "updated_at": "2026-03-03T09:02:21Z", "body": "I have read the CLA Document and I hereby sign the CLA", "author_association": "CONTRIBUTOR", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/3989623739/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null } ] }