Commit Graph

453 Commits

Author SHA1 Message Date
Girish Ramakrishnan 5ba8a05450 cifs: use rsync instead cp -aRl
for some reason, cp fails on synology cifs for some paths - immich's typesense dir
2026-02-23 17:47:05 +01:00
Girish Ramakrishnan 4ed6fbbd74 eslint: add no-shadow 2026-02-18 08:18:37 +01:00
Girish Ramakrishnan b5a1554631 Fix various linter errors 2026-02-15 19:37:30 +01:00
Girish Ramakrishnan e9f96593c3 reorder functions for no-use-before-define 2026-02-14 16:34:34 +01:00
Girish Ramakrishnan 36aa641cb9 migrate to "export default"
also, set no-use-before-define in linter
2026-02-14 15:43:24 +01:00
Girish Ramakrishnan 96dc79cfe6 Migrate codebase from CommonJS to ES Modules
- Convert all require()/module.exports to import/export across 260+ files
- Add "type": "module" to package.json to enable ESM by default
- Add migrations/package.json with "type": "commonjs" to keep db-migrate compatible
- Convert eslint.config.js to ESM with sourceType: "module"
- Replace __dirname/__filename with import.meta.dirname/import.meta.filename
- Replace require.main === module with process.argv[1] === import.meta.filename
- Remove 'use strict' directives (implicit in ESM)
- Convert dynamic require() in switch statements to static import lookup maps
  (dns.js, domains.js, backupformats.js, backupsites.js, network.js)
- Extract self-referencing exports.CONSTANT patterns into standalone const
  declarations (apps.js, services.js, locks.js, users.js, mail.js, etc.)
- Lazify SERVICES object in services.js to avoid circular dependency TDZ issues
- Add clearMailQueue() to mailer.js for ESM-safe queue clearing in tests
- Add _setMockApp() to ldapserver.js for ESM-safe test mocking
- Add _setMockResolve() wrapper to dig.js for ESM-safe DNS mocking in tests
- Convert backupupload.js to use dynamic imports so --check exits before
  loading the module graph (which requires BOX_ENV)
- Update check-install to use ESM import for infra_version.js
- Convert scripts/ (hotfix, release, remote_hotfix.js, find-unused-translations)
- All 1315 tests passing

Migration stats (AI-assisted using Cursor with Claude):
- Wall clock time: ~3-4 hours
- Assistant completions: ~80-100
- Estimated token usage: ~1-2M tokens

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 15:11:45 +01:00
Girish Ramakrishnan 42cefd56eb Fix uploader API to handle write stream errors
When the upload is aborted/abandoed because the source file is missing,
the write stream is never destroyed. This dangling write stream can
later error and cause a crash.

Instead, create the write stream on demand and nearer to pipeline() to
make sure we do 'error' handling.
2026-01-20 22:26:08 +01:00
Johannes Zellner 854fbe53be Use unique temporary ssh key file for each ssh remote operation
File operations may run in parallel so we cannot rely on a well defined
keyfilename
2025-12-12 15:50:32 +01:00
Johannes Zellner 1ef252fbc2 Revert "Rely on single private key file for optimized ssh remote fs operations"
This reverts commit aaebe01892.
2025-12-12 15:26:56 +01:00
Johannes Zellner aaebe01892 Rely on single private key file for optimized ssh remote fs operations 2025-12-12 14:44:19 +01:00
Girish Ramakrishnan c656903772 Use the simpler file.save to verify 2025-12-03 21:02:53 +01:00
Girish Ramakrishnan 61b5ab8a49 gcs: ensure handlers are attached before write 2025-12-03 20:36:55 +01:00
Girish Ramakrishnan 99c14533a5 gcs: fix copy operation
copy() is part of the interface and does not include the prefix.
2025-12-03 18:31:26 +01:00
Girish Ramakrishnan b759fdb6e3 s3: remove leading slash in CopySource 2025-12-03 17:11:51 +01:00
Johannes Zellner 043d89c03b Ensure we purge the ssh backup key file in case it was left over by a
previous failed backup run

fs.writeFileSync() would fail to overwrite due to restricted file mode
for ssh
2025-12-02 12:14:33 +01:00
Johannes Zellner c2378d33b4 Also use a temporary SSH identity file for optimized ssh remote rm -rf 2025-11-27 10:04:06 +01:00
Girish Ramakrishnan 4ef1339ba2 filesystem: handle non-existent prefix 2025-11-26 11:25:35 +01:00
Girish Ramakrishnan 917c18a423 s3: ensure endpoint has a scheme 2025-11-24 12:23:52 +01:00
Girish Ramakrishnan e106dcd76a storage: pass limits object to backend 2025-11-14 13:18:21 +01:00
Girish Ramakrishnan 98da4c0011 storage: apiConfig -> config
to keep this in sync with site.config
2025-11-14 13:03:14 +01:00
Girish Ramakrishnan fc0c316ef2 s3: also pick region from the config 2025-11-14 09:37:03 +01:00
Johannes Zellner afde81ef3e Use a temporary identity file for remote ssh copy 2025-11-13 10:27:33 +01:00
Girish Ramakrishnan ce15958a9a minio: fix issue with accepting selfsigned certs 2025-11-12 14:18:34 +01:00
Johannes Zellner 21191bdc50 Give sshfs identity files unique filenames across mounts
If the same host was mounted as volume and backup or as a temporary
backup import, sharing the filename of the identify file would mean it
will get removed while still in use
2025-11-06 16:25:06 +01:00
Girish Ramakrishnan a518ee83cc backups: show same filesystem warning
fixes #867
2025-11-05 16:58:22 +01:00
Girish Ramakrishnan de84b5113c mounts: always return message when getting status 2025-11-05 16:52:32 +01:00
Girish Ramakrishnan d6a4dd6965 backup sites: fix listing when status call errors
* fix backend to not retry in status call
* fix frontend to continue loading view if status errors
* fix connect-lastmile to show the exact path that is timing out
2025-10-16 14:13:31 +02:00
Girish Ramakrishnan 11f2acd702 init data with initial config and only mutate what we allow editing 2025-10-09 12:20:59 +02:00
Girish Ramakrishnan 43e426ab9f Revert "Add no-use-before-define linter rule"
This reverts commit fdcc5d68a2.

Unfortunately, this requires us to move exports to the bottom.
This in turn causes circular dep issues and also access of
exports.GLOBAL_VAR in the global context
2025-10-08 21:17:52 +02:00
Girish Ramakrishnan f2316ec84e storage: remove usage of secret placeholder 2025-10-08 15:49:56 +02:00
Girish Ramakrishnan f92cdf36f5 system: return the mounted and unmounted block devices (as long as xfs or ext4) 2025-09-23 18:51:23 +02:00
Girish Ramakrishnan 305441ea28 backups: remove noop backend
the noop backend is migrated into 0 sites config.

when the updater code sees that there is no site to backup, it will
just fail. user has to manually update with skipBackup flag.
2025-09-22 16:44:12 +02:00
Girish Ramakrishnan 43cc91aca2 fix tests 2025-09-13 15:22:01 +02:00
Girish Ramakrishnan 31df40a841 storage: add copyDir
we changed listDir in c44863a9bb to list
a directory . this broke copy for files since a '/' is added when listing
the file.
2025-08-26 00:01:14 +02:00
Girish Ramakrishnan c44863a9bb s3: ensure we list directory
<timestamp>/box_v9.0.0.backupinfo ends up getting listed
when trying to list <timestamp>/box_v9.0.0 !
2025-08-25 19:15:21 +02:00
Girish Ramakrishnan 832a25601d storage: make listDir return paths relative to the root
this seems more natural to work with
2025-08-16 18:13:02 +05:30
Girish Ramakrishnan f2225ff6b6 fs.rmdirSync { recursive: true } is deprecated 2025-08-14 13:43:41 +05:30
Girish Ramakrishnan 12e073e8cf use node: prefix for requires
mostly because code is being autogenerated by all the AI stuff using
this prefix. it's also used in the stack trace.
2025-08-14 12:55:35 +05:30
Girish Ramakrishnan fddbe6a574 Fixup tests 2025-08-04 23:11:50 +02:00
Johannes Zellner a887be432b Create correct mount objects for mountpoint validation 2025-08-04 15:25:27 +02:00
Johannes Zellner 705311f01f Fix typo 2025-08-04 15:17:27 +02:00
Johannes Zellner 1016d41d7a Rename backup label to name and separate backup listing into new view 2025-08-04 15:00:24 +02:00
Johannes Zellner 90c82ab1e7 make sure we only use mount objects with the mounts api 2025-08-04 14:40:35 +02:00
Johannes Zellner cf1e1aac77 Fixup some refactoring issues in mounting ext4 2025-08-04 13:32:12 +02:00
Girish Ramakrishnan 7ef9e7eb51 storage: add getStatus hook 2025-08-04 11:01:20 +02:00
Girish Ramakrishnan 547d8ae113 filesystem: rename backupFolder to backupDir 2025-08-02 10:37:37 +02:00
Girish Ramakrishnan 4fcaae8053 backup: fix listDir to return path instead of fullPath 2025-08-02 10:24:51 +02:00
Girish Ramakrishnan c935744f4c backups: root ~~canal~~ path surgery
remove rootPath and getBackupFilePath from the backup target and
make this backend specific.
2025-08-02 10:15:34 +02:00
Girish Ramakrishnan a01e1bad0f backuptarget: pseudo target for import and restore 2025-08-02 00:06:47 +02:00
Girish Ramakrishnan 53e9925880 backups: make id, provider a backend specific setting
the backend can stash whatever values it wants in the config.
just like the DNS backends, we make verifyConfig return a sanitized config.
added benefit is that extra user fields (via API) are also not dumped into the db.
2025-08-01 18:55:04 +02:00