Commit Graph

728 Commits

Author SHA1 Message Date
meld-cp
77f2e5581f feat(ui): added locale to UIPreferences (#4741) 2025-08-08 14:41:35 -07:00
Jarek Kowalski
0733cb4d2a fix(server): fixed scheduling bug (#4732)
This was a very stupid bug introduced in
https://github.com/kopia/kopia/pull/4682

Fixes #4729
2025-07-22 00:51:29 +00:00
Julio Lopez
347adbfff1 fix(general): add {peta,exa}byte prefixes (#4707)
- add {peta,exa}byte prefixes
- add test cases for units conversion
- refactor tests for units package
2025-07-01 18:39:01 -07:00
Julio Lopez
89d1bbc743 chore(general): minor cleanups (#4704)
- use `slices.Clone`
- remove stale `.gometalinter.json`
- unexport `maintenance.dropDeletedContents`
- rename `fetchIndexBlob`
- use `require` in `TestTimeFuncWiring`
2025-07-01 12:05:50 -07:00
Leonardo Cecchi
a8fc80f47c feat(cli): add --disable-file-logging to suppress log file output (#4686) 2025-06-26 14:42:30 -07:00
Jarek Kowalski
4256e87d56 fix(server): fix snapshot scheduling in the event of machine goes to sleep (#4682)
Fix snapshot scheduling in the event of machine goes to sleep

- Fixes #3512
2025-06-24 12:47:11 -07:00
Julio Lopez
126395f292 refactor(general): migrate to crypto/{hkdf,pbkdf2,sha3} (#4678)
Functional changes:

- Key derivation no longer panics, instead it returns an
  error on failed condition checks.
- Migration to crypto/hkdf required changes in various
  function signatures, adding an error return value for
  propagating key derivation errors up the calling chain.
  Tests were refactored to account for the signature change as well.


Non-functional changes:
- migrate to crypto/pbkdf2
- migrate to crypto/sha3
- migrate to crypto/hkdf
- add deriveHMACSecret function to simplify caller function
- simplify deriveHMACSecret
- fix test: specify non-empty HMACSecret
2025-06-19 21:25:02 -07:00
Julio Lopez
735adfcf85 refactor(general): small misc. cleanups (#4666)
* remove unnecessary type argument
* modernize with max
* unexport getPartial and update comment
* unexport getFull
* verifyNotCached helper
* use require helpers
* leverage verify[Not]Cached
* use windowsOSName const
* fix comment wrapping
* require in stat_test
* use 512 as the write size and log allocated size
* rename const to expectedMinAllocSize
* write a single byte to test file
* add TestGetBlockSizeFromCurrentFS
* require Positive
* log before invariant check
2025-06-13 23:56:37 -07:00
Nathan Baulch
19d92613a6 chore(general): typos (#4659) 2025-06-10 17:24:14 -07:00
Julio Lopez
e1d065aee1 refactor(general): misc cleanups (#4652)
- use raw strings for readability, removes escaping
- clarify comment
- add self-documenting message to test assertion
- always cleanup test file
- refactor(test): cleanup TestParseSnapListAllExeTest
- nit: call getLogOutputPrefix once
- rename SkipTestUnlessLinux
- inline TestSkipUnlessCI
- rename SkipTestOnCIUnlessLinuxAMD64
2025-06-04 22:58:01 -07:00
Julio Lopez
206a5fb161 nit: continue in loop and reduce indentation (#4623) 2025-06-04 22:27:02 -07:00
Julio Lopez
81539eee8f chore(ci): include date-time in temp dir name used for tests (#4651)
While sorting by modification time is possible with OS tools,
such as `ls`, including the directory creation time in the
name facilitates cleanup in local dev environments where
tests fail often.
2025-06-04 20:07:05 -07:00
Julio Lopez
d91a5a8f94 chore(general): enable forcetypeassert linter (#4624)
- enable `forcetypeassert` linter in non-test files
- add `//nolint` annotations
- add `testutil.EnsureType` helper for type assertions
- enable `forcetypeassert` linter in test files
2025-05-31 23:17:38 -07:00
Jarek Kowalski
021d8a5ad2 chore(repository): create minimal cache.Storage interface (#4618)
Extracted blob.Lister interface
2025-05-29 17:58:42 -07:00
Julio Lopez
ab1f62e3ad refactor(general): misc cleanups (#4615)
- nit: rename var to packCountByPrefix
- leverage impossible package
- use maps.Clone
- unexport indirectObjectID
- unexport compressed
- rename function to flushBufferLocked
- add checklocks annotations to functions that must be called under w.mu
2025-05-29 08:26:55 -07:00
Julio Lopez
3d4c5f8f9e refactor(general): s/interface{}/any/ (#4614) 2025-05-29 06:07:49 +00:00
Jarek Kowalski
1ee24977ce fix(notifications): fixed notification severities on snapshot creation (#4604) 2025-05-25 16:25:35 -07:00
Jarek Kowalski
fec575bd90 fix(server): fixed server-based notifications (#4598)
* fix(server): fixed server-based notifications

Used TypedEventArgs instead of `any` to ensure all notification data
carries type information, allowing the server to property deserialize it.

* fix
2025-05-24 08:15:45 -07:00
Julio Lopez
2910801f0e test(cli): minor cleanups in diff tests (#4594)
Minor cleanups in diff tests: helper to generate (direct) object ids.
- nit: rename variables for consistency
- nit: Use `k` prefix in oids where appropriate
- nit: remove unnecessary intermediate vars
- nit: specify known map length
2025-05-23 20:27:13 -07:00
Rohit-BM18
dbf5bacdc8 feat(cli): helper functions to get preceding snapshots for diff (#4559)
Add helper functions and relevant tests for fetching previous snapshot manifests
2025-05-13 04:14:33 +00:00
Rohit-BM18
12409c7279 feat(cli): --stats-only flag for the diff command (#4557)
Adds a `--stats-only` flag to the `diff` command to reduce
output verbosity.
When `kopia diff` is invoked with the `--stats-only` flag it
only outputs the aggregate statistics of changes.
2025-05-05 20:59:52 -07:00
ashmrtn
f5d3e09bda Allow external callers to name jsonencoding type (#4552)
As jsonencoding is used to pass some config parameters, move it to a
package that callers external to kopia can name. This ensures they can
actually configure those parameters if needed.
2025-05-02 09:36:08 -07:00
Julio Lopez
31a1fd25ba style(general): cleanup linter config (#4538)
- use 'localmodule' for gci linter config
- enabled 'wastedassign' linter
- remove unused assignment
- prevent re-introducing dependencies
- remove unused //nolint directive
- disable zerologlint linter
2025-04-30 10:37:03 -07:00
Julio Lopez
8098f49c90 chore(ci): remove exclusion for unused ctx parameters (#4530)
Remove unused-parameter exclusion for `ctx` in revive linter.

---------

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-04-26 23:11:36 -07:00
Matthieu MOREL
8a176255c0 fix(general): enable wsl for all go files (#4524)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-04-26 13:01:20 -07:00
Julio López
e38145d288 fix(cli): create cache marker in log directories (#4517)
- Fixes #2822
- Initial PR: #3147

Thanks to @NickIAm for the initial PR.
2025-04-22 21:36:29 -07:00
Julio López
e3fc6e012d refactor(general): leverage os.CreateTemp (#4513)
* use `os.CreateTemp` in `tempfile.CreateAutoDelete`
* refactor `TestTempFile`: add `VerifyTempfile` test helper
* add test for `createUnixFallback`
* rename function to `tempfile.CreateAutoDelete`
* remove the `dir` parameter to `tempfile.CreateAutoDelete`,
  only an empty string was passed, apart from test cases.
* guard against panic in TestShadowCopy
2025-04-22 20:55:11 -07:00
Julio López
3712fc4873 chore(ci): enable exptostd linter (#4509)
Also, cleanup `x/exp/constraints` usage to address linter warning.

Ref:
- #4500
- #4507 (contains prior migration from `x/exp` to stdlib packages)
2025-04-17 10:19:27 -07:00
Julio López
09b88d3860 chore(general): minor cleanups and other nits (#4507)
* use uint8 for clarity
* unexport writeContentAsyncAndVerify
* fix typo in test function name
* remove commented interface functions
* use atomic.Int32
* cleanups in socket server activation test
* leverage stdlib's maps and slices packages
  replace uses of `golang.org/x/exp/maps`
* nit: leverage `maps.Values`
2025-04-16 23:25:01 -07:00
Matthieu MOREL
675e958877 chore(ci): bump golangci-lint to v2.1.2 (#4500)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-04-15 22:49:13 -07:00
Julio López
97ff2a17fb fix(general): tempfile.Create on Linux (x64/arm64) (#4504)
- Add `TestCreateSucceedsWhenDirIsNotSpecified`
- Use `os.TempDir` when `dir` is not specified (empty string)

Ref:
- Fixes #4331
- Fixes #2415
2025-04-15 22:21:57 -07:00
Julio López
5c8e58e07a refactor(cli): misc cleanups in internal/diff (#4484)
- remove spurious log message, duplicates what is being sent to the output;
- nit: update struct comment;
- consolidate code via a parameterized function;
- rename variable for clarity, it makes it easier to understand by avoiding negative condition check;
- remove unused return value;
- replace if blocks with switch.
2025-04-02 15:40:32 -07:00
Julio López
ad33441fbc chore(cli): add details to persistent password error message (#4480)
Extends error message with a generic, OS-independent hint about
what the source of the error may be and a potential solution.

Also, modifies error message to avoid duplicate messages.

- kopia/kopia#4449
2025-03-31 21:10:21 -07:00
Jarek Kowalski
51de24dcff refactor(snapshots): refactored uploader into separate package (#4450) 2025-03-14 15:48:31 -07:00
Rohit-BM18
9b68189d29 feat(cli): compute snapshot diff stats (#4444)
Added functionality to calculate aggregate statistics when
comparing what's changed between snapshots using kopia diff

Statistics collected during snapshot diff computation includes:

- files added/removed/modified
- dirs added/removed/modified
- files/dirs with metadata changes but same underlying content (OID)

Testing approach:

Added a test for verifying stats collected when comparing two directories with the same objectID but metadata changes across snapshots (dir mode, dir mod time, dir owner, etc), expectation is all the appropriate dir stats fields are updated.
Added another test for verifying stats collected when comparing two directories with similar file contents but the metadata for the files have changed between snapshots but content remains unchanged. Expectation is all the relevant file level stats fields are updated.
Existing tests have been updated due to stats now being printed in addition to previous output.
2025-03-07 12:41:14 +00:00
Julio López
8f632e4e1f refactor(cli): diff test (#4422)
- Use a single struct and implementation for common functionality
- set type in Mode() for directories
- nit: fix typo
2025-02-21 21:57:22 -08:00
Julio López
3fbe0bd424 fix(server): prevent maintenance task on read-only repos (#4408)
Avoid starting a maintenance task on the server when
the repository connection (configuration) is read-only.

Also:
* Check for read-only repo before running maintenance.
* Move direct repo check to startMaintenanceManager.
* Rename function as maybeStartMaintenanceManager.
  The name reflects that the function may not start a
  maintenance task manager.
* Add connect options to repotesting.
* Add test for maintenance on read-only repo.

- Fixes: #4373
2025-02-13 20:13:22 -08:00
Julio López
2a22281271 fix(server): ensure server uploads "repodiag" blobs (#4358)
The kopia server was not uploading any logs to the repository,
because "repodiag" blob uploads would always fail.

The cause was the following: when the (log) repodiag blob
PUT operation was initiated, the `Context` used for this
operation was already canceled.

The context used for blob uploads is passed to
`repodiag.NewLogManager` when opening the repository.
In the case of the kopia server, the repository is asynchronously
opened in `server.Server.InitReposotoryAsync`. The context
passed to `repo.Open` is canceled after the "open repository"
server task completes.

This issue was introduced in #1691

Change:
Use `context.WithoutCancel()` instead of the context passed
when the repo diagnoser is created.

New tests are included to reproduce this failure and verify
the fix.
- test: ensure server logs are uploaded to the repo
- test: honor cancellation in map storage
- test: repodiag context cancellation

Ref:
- #1691
2025-01-22 20:13:39 -08:00
Jarek Kowalski
d6b9254a4c feat(notifications): emit snapshot report notifications in the UI/server (#4323)
* feat(notifications): emit snapshot report notifications in the UI/server

* added test

* fixed data race
2024-12-30 10:59:11 -08:00
Jarek Kowalski
c1757a0c67 feat(general): misc notifications improvements (#4319)
* feat(general): various notifications improvements

* added API to test notification profiles
* added --http-header to webhook notification configuration
* refactored configuration to always apply defaults before persisting options in the repository
* added 'notification profile show --profile-name=X' command

* more tests

* more test coverage

* report notification code coverage
2024-12-29 09:50:20 -08:00
Jarek Kowalski
75e844d21f feat(server): only log successful authentication events when --log-server-requests is enabled (#4296) 2024-12-07 11:18:17 -08:00
Julio López
c70f1a1c11 feat(general): JSON marshaler helper for time.Duration (#4194) 2024-11-19 23:00:48 -08:00
Mario Camou
5ce6b8d2bd feat(snapshots): Fix for #2037 Add symlink support for .kopiaignore (#4190)
* Add symlink support for .kopiaignore

* Address PR comments

* Fix linting
2024-11-19 06:45:24 +00:00
Julio López
666899cefc fix(server): handle unset password hash version in user profile (#4259)
- Fixes: #4257
- Fix: Handle case when the hash version is unset in the user profile
- Add tests for default password hash
- Fix failing authenticator test: When the password hashing version
  is not set, then the default one is used, so verifying the password
  works.

Refactor authenticator tests:
- Nit: rename test variable
- Check error when calling SetPassword
- Add comments for test cases
- Nit: user assert.Equal in verifyRepoAuthenticator
- Split repository authenticator tests to test invariants separately
2024-11-17 22:26:58 -08:00
Jarek Kowalski
b60cac4860 fix(cli): fixed v0.18.0 failures using v0.17.0-generated config (#4255)
This was caused by the client using key derivation algorithm
from a config file (which did not have it when it was generated
using old version of Kopia).

Fixes #4254
2024-11-17 10:15:00 -08:00
Jarek Kowalski
eb1cf64c27 chore(ci): upgraded linter to 1.62.0 (#4250) 2024-11-16 07:16:50 -08:00
Jarek Kowalski
91d00e8256 feat(providers): upgraded rclone to 1.68.2, fixed Google Drive rclone compatibility (#4249)
* chore(ci): upgrade rclone to 1.68.2

* fix(providers): fixed Google Drive rclone compatibility
2024-11-15 20:02:08 -08:00
Linus
a0c5e57e4a Add logging of failed and successful login attempts (#4234)
for monitoring, troubleshooting, and to allow using tools like crowdsec or fail2ban
2024-11-11 18:46:07 -08:00
Jarek Kowalski
afb85cbb34 feat(cli): send error notifications and snapshot reports (#4233)
* feat(cli): send error notifications and snapshot reports

Notifications will be sent to all configured notification profiles
according to their severity levels.

The following events will trigger notifications:

- Snapshot is created (CLI only, severity >= report)
- Server Maintenance error occurs (CLI, server and UI, severity >= error)
- Any other CLI error occurs (CLI only, severity >= error).

A flag `--no-error-notifications` can be used to disable error notifications.

* added template tests

* improved time formatting in templates

* plumb through notifytemplate.Options

* more testing for formatting options

* fixed default date format to RFC1123
2024-11-11 17:53:50 -08:00
Eugene Sumin
f0541ab67e feat(cli): introduce adaptive estimation mechanism (#4218)
* Add rough estimation mechanism

* Extract data size estimation scan to standalone function

* Introduce estimation type flag

* Change signature of EstimatedDataSize

* Extract estimation logic and test it

* Adjust err handling in GetVolumeSizeInfo

* Make GetVolumeSizeInfo reusable

* Fix type issue for windows platform

* Use adaptive estimation with threshold
2024-11-04 17:31:09 -08:00