Commit Graph
320 Commits
Author SHA1 Message Date
Kenneth Skovhede 179d1ceb47 Make controller Async
This PR has a large blast radius because it takes the final step and bumps up the Controller to be fully async.

We have historically done a piece-by-piece update, so all operations were already async but the controller interface was kept synchronous.

With this update, the controller is now fully async and all tests are updated.

Most places where the new C# compiler warns about function names not ending in `Async` were also adressed, giving a massive refactor change.

Functionally, no changes are done.
2026-05-13 15:04:13 +02:00
Kenneth Skovhede 4244e71fee Improve SQL logging
This PR improves SQL logging by capturing many places where the calls would previously just hit the database and not produce any logging output.
2026-05-06 10:52:58 +02:00
Kenneth Skovhede c0f40e19ca Updated copyright year to 2026 across the project 2026-04-16 15:21:24 +02:00
Kenneth Skovhede cf02c1addf Fixed large SQLite inputs
When performing queries with large inputs, there is a possibility that we reach the maximum number of possible parameters. If the query exceeds the maximum number of parameters the query fails.

This change uses a temporary table that will be created in the case the inputs exceed the total number available parameters, making sure the calls proceed as before with small inputs, but uses temporary tables on larger inputs.

Some tests were added to ensure the update works as expected, even with large inputs.
2026-02-11 13:34:58 +01:00
Kenneth Skovhede e7aa60fba0 Handle duplicate source paths
This PR adds guards to prevent creating filesets with multiple files that have the same path.

While it should technically be impossible to have multiple entries that have the same path, it could happend either due to glitches or because the source data (manual lists, remote sources, etc) returns duplicates.

This PR adds a simple check for each folder to ensure that on a folder-level, duplicate paths cannot be introduced.

There is also a post-backup check to evict any duplicates, and the recreate process will reject duplicate paths.

Finally, the repair command will remove duplicates if they somehow manage to get into the database anyway.

A database-level prevention is not currently feasible as it needs a cross-table check for uniqueness, which requires more work from the database to check for each added file. Since this is expected to be a very rare event, the added processing was not justified.
2026-02-05 11:06:41 +01:00
Kenneth SkovhedeandGitHub 4b2402d381 Merge pull request #6733 from duplicati/feature/fix-issue-6539
Fix issue with failed delete
2026-01-30 16:19:59 +01:00
Kenneth Skovhede cee97bb01a Treat inconsistency state the same for both deleted and deleting, so a failed delete does not cause a database inconsistency 2026-01-30 15:09:17 +01:00
Carl-Johannes JohnsenandGitHub 6b02116bed Merge pull request #6708 from carljohnsen/feature/automatic-321
Feature/Automatic 3-2-1 backup
2026-01-28 17:21:33 +01:00
Kenneth Skovhede bb2be7966e Fixed issue with missing log
When an error occurred, the log would be written to the database, but the transaction would then be rolled back, causing the log to disappear.

This adds explicit commit to the log when handling error cases.

This fixes #6538
2026-01-27 21:08:36 +01:00
Carl Johnsen 177272ecd9 Merge branch 'master' into feature/automatic-321 2026-01-08 20:55:31 +01:00
Carl Johnsen 50f18dca84 Moved ResultSerialization from builtin modules to a shared library 2026-01-08 14:34:11 +01:00
Kenneth Skovhede 557fbd12d9 Fixed nullable issues 2026-01-06 10:22:53 +01:00
Kenneth Skovhede 625c56b5c1 Updated new column to be not null, for consistency with other columns 2025-12-17 23:04:47 +01:00
Kenneth Skovhede 6e6e993765 Fixed issues with database transaction not being comitted.
Renamed the options to be more descriptive.
Rewrote the dependency query to be more readable and also check for metadata dependency.

Fixed an edge case where there were no modified files, and no new backup is created.

Fixed some issues with local/utc datetime compares.

Fixed logic for deleting filesets to only look at the filesets themselves. This makes the version lock follow the dlist file, and can create "dangling" volumes that have no filesets, but these will be picked up by compaction.

Updated tests to work correctly.

Added lock-info update option for the backup recreate call, so the UI can also re-create lock information on database rebuilds.
2025-12-17 22:27:38 +01:00
Kenneth Skovhede 0f81b42146 Add support for remote locks
This PR adds support for locking files if the backend supports it.

To activate locking, set the option `--file-lock-duration=30D` and the backup will lock the files.

If the database is rebuilt with the intention of continuing the backups, use the option `--repair-refresh-lock-info` which will update lock information in the database after recreating the database.

The locking works by asking the backend to lock files after a backup has completed.

The implementation keeps track of which files are currently assigned a lock and prevents attempting to delete the files that are currently locked.

Note that the bucket should not have a default lock policy as Duplicati needs to finish the backup before the locking is applied.

In this initial version, Azure Blob Storage, B2, S3 and iDrive are supported with locking.

The CLI is updated to allow setting locks on a specific version. The backend tool is updated to allow setting locks on specific files.
2025-12-14 17:17:48 +01:00
Kenneth Skovhede 7322c46861 Pre-execution check for RemoveRemoteVolumes
This PR adds a check before entering the RemoveRemoteVolumes that checks if there are dangling FilesetEntry records when calling the function.

This makes it possible to figure out if the problem is created by the RemoveRemoteVolumes code, or an already existing problem in the database.

Also added a few tests that check that the condition is correctly detected.
2025-12-03 11:34:30 +01:00
Kenneth Skovhede 230d80642a Fixed invariant formatting helpers
This fixes an issue with formatting for invariant values that was caused by incrorrect function overload selection.

To avoid future issues, the two similar functions have been renamed to clarify what they are working for.
2025-09-25 11:14:54 +02:00
Kenneth Skovhede f0d8677ef5 Include duplicated blocks in recreated index files
This fixes #6504
2025-09-23 11:12:36 +02:00
Carl Johnsen 7670ea9a58 Ensured that all values that are passed to interpolation strings have been passed through FormatInvariant to prevent SQLite errors related to string formatting cultures. 2025-09-05 14:11:05 +02:00
Carl Johnsen b3fe276a13 Ensured that all temporary tables uset the same type of generated guid name 2025-09-05 14:06:55 +02:00
Kenneth Skovhede 429bcd1f2d Include deleted blocks when recreating dindex files.
This fixes #6339
2025-07-11 15:55:36 +02:00
Carl Johnsen 0a047a37e3 SQL query inside GetEmptyMetadataBlocksetId had not only moved files, but had also changed 2025-06-19 13:20:44 +02:00
Carl Johnsen f6ac30e831 Merge remote-tracking branch 'upstream/master' into performance/mssqlite-async 2025-06-19 12:17:30 +02:00
Carl Johnsen 2412800c0c Removed the sqlite page cache option. It should be set through the environment variable, or some other way of providing a custom database configurotion 2025-06-19 11:41:39 +02:00
Carl Johnsen 3b3a7801b8 Made the LocalDatabase methods accept a cancellation token 2025-06-18 15:36:10 +02:00
Carl Johnsen bc97eaf71b Removed redundant calls to a SqliteCommand.Parameters.Clear() 2025-06-18 12:06:20 +02:00
Carl Johnsen 9ac583db94 Made all relevant using statements use await to use DisposeAsync 2025-06-18 11:53:11 +02:00
Carl Johnsen 859b65054d Simplified using statements that uses databases or accesses their methods 2025-06-18 11:52:05 +02:00
Carl Johnsen f221098c28 Formatted SQL queries - mainly adding double quotes where they were missing. 2025-06-18 10:42:08 +02:00
Carl Johnsen 8814fdebcc Added more docstrings 2025-06-17 15:13:33 +02:00
Carl Johnsen 1f97832546 Classes implementing DisposeAsync should also implement the interface 2025-06-17 15:11:25 +02:00
Kenneth Skovhede 2c5c01160c Added a check and repair for empty metadata
This PR adds a check for empty metadatasets (length = 0) and replaces such sets with a default metadataset.

This fixes #6350
2025-06-16 16:35:07 +02:00
Carl Johnsen 3d11a05400 Added .ConfigureAwait(false) to all of the await statements 2025-06-12 08:34:29 +02:00
Carl Johnsen e5337e4d26 Formatted SQL queries 2025-06-11 12:09:58 +02:00
Carl Johnsen 09251284ab Removed TODOs 2025-06-11 11:07:54 +02:00
Carl Johnsen f373880c5a Renamed ExpandInClauseParameterAsync, as one of them isn't actually async.
Postfix mssqlite has been added as well to not clash with the IDb implementation
2025-06-11 10:47:40 +02:00
Carl Johnsen 66ed9600b8 Removed unused synchronous helper method 2025-06-11 07:38:24 +02:00
Carl Johnsen 73c8471f8e Made BlocklistHashEnumerable and the code using it async 2025-06-11 07:37:22 +02:00
Carl Johnsen 23509a27eb Disposing the database disposes the reusable transaction and creates it's own transaction for PRAGMA optimize 2025-06-05 09:15:17 +02:00
Carl Johnsen 507087df1d Calling close on the connection, as that calls the backend directly, and not through the IDb interface 2025-06-05 09:13:40 +02:00
Carl Johnsen 85e6f45338 Moved some of the commits to transactions outside of database methods, as this more closely mimics the commit flow of the old IDb backend.
This was especially needed due to the Microsoft.Data.Sqlite backend not supporting nested transactions.
2025-06-03 21:44:55 +02:00
Carl Johnsen caa3c13dbe Post master merge fixes 2025-06-02 11:50:35 +02:00
Carl Johnsen 04ffb4fb42 Fixed incorrectly merged changes in LocalDatabase 2025-06-02 09:16:25 +02:00
Carl Johnsen ee40767412 Merge branch 'master' into performance/mssqlite-async 2025-05-27 12:04:50 +02:00
Kenneth Skovhede 721e497e69 Fixed nullability warnings 2025-05-23 11:46:37 +02:00
Carl Johnsen d27dec0a2f Updated methods to use the instance ReusableTransacition instead of starting a new one 2025-05-23 08:26:06 +02:00
Carl Johnsen abc7c79841 Dispose made infinite recursion between different class derivations 2025-05-23 08:20:00 +02:00
Carl Johnsen afa468377b Fixed typo 2025-05-22 15:28:46 +02:00
Carl Johnsen 6c7e67dd28 Post master merge fixes 2025-05-22 14:35:15 +02:00
Carl Johnsen a37f0dda31 Merge branch 'master' into performance/mssqlite-async 2025-05-22 14:09:17 +02:00