Commit Graph
62 Commits
Author SHA1 Message Date
Kenneth SkovhedeandGitHub d99f74ed94 Rewrite the backend manager. (#5896)
* Rewrite the backend manager.

This creates a new more logic backend manager that handles all backend operations.

For each top-level operation, there is now a single backend manager instance that is passed to sub-commands.

The internals of the backend manager are now rewritten to use async logic instead of threading.

The design uses a single task runner that dispatches operations and honors concurrent settings and limits from one place.

The logic for each operation has been moved into a separate files/classes to make it easier to understand each operation.

This fixes #5804

* Fixed a few issues with not awaiting tasks

* Fixed not creating empty databases

* Fixed an issue with hashes not being recorded on download

* Reworked the download logic to avoid attempting to decrypt the file if it has been modified.

* Review fixes

* Renamed db collector to better reflect the purpose.

* Review fixes
2025-01-28 08:54:50 +01:00
Kenneth SkovhedeandGitHub edd69bfd59 Improve cancel robustness 2 (#5882)
* Attempt to avoid comitting transaction without any queries being made

* Guard internal logic
2025-01-16 16:01:54 +01:00
Kenneth SkovhedeandGitHub 382ba172b3 Fixed duplicate entries in index files (#5856)
* Added test to verify that compression modules will mask duplicate entries, if present

* Because there are likely many, otherwise valid, dindex zip archives with duplicated blocklists out there, the log message is now verbose.

To make sure we no longer create archives with duplicated entries, the `--unittest-mode` option makes this a warning that is checked in most tests.

* Added guard in `IndexVolumeCreator` to prevent creating zip files with duplicated block lists.

* Added debug check for duplicates

* Fixed the duplicate test
2025-01-10 09:24:31 +01:00
Kenneth SkovhedeandGitHub 9464caf622 Feature/update license 2025 (#5851)
* Fixed some minor whitespace issues

* Updated all copyright to 2025
2025-01-07 09:40:39 +01:00
Kenneth SkovhedeandGitHub ff1b2b7990 Simplified task control (#5753)
* Simplified task control by having all logic in a single class and using async control mechanism
* Fixed the tests
* Made the marking of a backup partial explicitly communicated if the enumeration process is stopped.
* Added support for pausing active transfers
* Introduced transfer token to abort operations.
* Updated the way LiveControl is emitting events.
* Retains the paused state of the server across reboots, this fixes #5760.
* Reworked the way throttle speeds are propagated through LiveControls.
* Added option to pause transfers in the UI.
* Removed throttle settings from the LiveControls class so it is exclusively handled by the ApplicationSettings.
* Removed `thread-priority` as it does not work at all when tasks are used.
* Fixed the stop dialog and API to only support stop and abort.
* Removed unused variables
2024-12-18 08:27:59 +01:00
Kenneth Skovhede b280432476 Changed logic to use HashCalculatingStream instead of CryptoStream, which should fix #4094.
Removed VolumeHashFactory as it dit not support using another hashing algorithm for volumes.
2024-09-28 11:13:06 +02:00
Kenneth Skovhede 473c6cbbb8 Merge commit '4f577c65a4d8806f79637c50c21ca3a683c5a07a' into feature/kestrel-avalonia-upgrade 2024-03-04 12:21:53 +01:00
Kenneth Skovhede d16d702975 More fixes for stray using directives 2024-02-28 20:42:33 +01:00
Kenneth Skovhede 40dd3c6816 Updated all license mentions to MIT 2024-02-28 15:45:30 +01:00
Thomas Suckow ecb0249259 dotnet no longer provides a method for a string to hashalgorithm
* Also fix up not diposing of hashers
2021-04-04 11:17:13 -07:00
Thomas Suckow d8ddd6982c Refactor VolumeHash 2021-04-04 08:28:44 -07:00
Max c882953fdd upstream 2020-05-31 13:50:13 +02:00
Kenneth Hsu 0c9ca9a75c Remove unused BackendHandler members. 2020-03-29 16:48:19 -07:00
Sean Templeton 9739517b0a Fix bandwidth throttling inconsistency
In code the throttling generally works backwards than what one would expect.
The streams that are throttled are the streams that operate on files from the local machine.
This fixes the download throttling not working and the upload throttling applying to
both uploads and downloads.

When doing a Put operation the stream on the local machine is reading from the
local filesystem and hence the upload throttle bytes per second needs to be
applied to the reading of the stream, not the writing.

Similarly when doing a Get operation the download throttle bytes per second needs
to be applied to the writing of the stream.

Fixes #4115
2020-03-04 19:57:48 -06:00
Max 41a5591532 upstream 2019-12-25 16:34:56 +01:00
Fish 3cf01b7297 Advance the progress bar when files are skipped. Fixes #3407.
According to the current implementation, the progress bar does not advance
when files are skipped by FilePreFilterProcess. This causes users'
confusion since the web frontend will get stuck at a certain stage for a
long time. This commit addresses this issue.
2019-11-03 21:34:21 -07:00
Kenneth Hsu 2aa76881a5 Mark fields that don't need to be reassigned as readonly.
This makes it explicit at compile-time that these fields should not be
reassigned outside the constructor.
2019-10-19 13:59:22 -07:00
Michal Naiman 1bc1e58737 upstream 2019-04-28 13:45:26 +02:00
Sean Templeton ac08aa2fb1 Dynamically throttle and track the progress of concurrent uploads
Changed AddBackendEvent() in ResultClasses to allow the option to not update
the backend progress. This allows the  BackendUploader to log the act of starting
an upload without changing the backend progress. The backend progress is now
handled by a new class, FileProgressThrottler, which will determine the transfer
rate of all uploads currently in progress.

This class also handles throttling the upload streams. The algorithm will try
to decrease or increase the streams throttle rates as appropriate by changing
the value based on the over/under amount or based on a percentage to prevent
throttling one stream directly to zero.
2019-03-05 21:25:35 -06:00
Sean Templeton 05c3f4808c Move encrypting, hashing, and creating index volumes out of BackendUploader
Encrypting, hashing, and creating index volumes are now done
in the DataBlockProcessor and the SpillCollectorProcess. This allows
uploads to always be transferring data and not have to stop to create
a file, encrypt data, etc.
2019-03-03 21:41:09 -06:00
Sean Templeton 4f4529a88a Move upload related code from BackendHandler to BackendUploader
As the BackendUploader is in charge of uploads the code has been moved
there to centralize the responsibility and prepare for parallel uploads.
2019-03-03 21:35:09 -06:00
Rune HenriksenandGitHub be7edb580d Merge pull request #3410 from warwickmm/simplify_enumerating_collections
Simplify enumeration of collections
2018-10-07 19:06:28 +02:00
Kenneth Hsu 0c1ac9c489 Replace chained LINQ calls with call to overload with predicate.
This simplifies the code by reducing the number of enumerators created
while also making the code slightly more readable.
2018-10-06 16:20:18 -07:00
Kenneth Hsu d72128ec83 Remove unused method parameters. 2018-10-06 15:09:43 -07:00
Kenneth Hsu 1c8bb276b4 Allow tasks to complete on any thread when context is irrelevant.
When the code following the await can be executed on any thread, it's
recommended to use ConfigureAwait(false) to avoid unnecessary context
switching and potential deadlocks.
2018-09-19 16:57:17 -07:00
Max a22a7a7d24 remove of FasterHashing component 2018-09-09 14:42:40 +02:00
Rune HenriksenandGitHub b8e53cc839 Merge branch 'master' into remove_unnecessary_async 2018-09-04 21:27:11 +02:00
Kenneth Skovhede b55893ec02 Rewrote the SingleRunner class to use a single mutex instead of the overly complex bag-of-tasks method.
This simplifies things and speeds up database query queuing, at the expense of not guaranteeing that the same thread will access the database, but just guaranteeing single threaded database access.
2018-08-07 09:52:18 +02:00
Kenneth Hsu 1a2ee3a5ef Simplify return type of synchronous methods.
Since these methods no longer have the async modifier, they do not need
to return a Task, and do not need to be awaited.
2018-07-04 15:35:14 -07:00
Kenneth Hsu 6c38651f19 Rename methods to clarify their synchronous behavior.
Since these methods no longer have the async modifier, we should not
include 'Async' in their names.
2018-07-04 15:35:14 -07:00
Kenneth Hsu 5e3f15ada4 Remove async modifier from methods that lack await.
A method marked async that does not use await will run synchronously.
By removing the async modifiers, we make it more explicit that these are
synchronous methods.  This also addresses some compiler warnings, and
avoids the creation of the state machine used to handle asynchronous
operations.
2018-07-04 15:35:09 -07:00
Kenneth Skovhede 166ef2976b Merge branch 'feature/cleanup_temp_files'
# Conflicts:
#	Duplicati/Library/Main/Operation/Common/BackendHandler.cs
2018-06-28 12:17:22 +02:00
Kenneth Hsu 54c4f9224d Allow tasks to complete on any thread when context is irrelevant.
When the code following the await can be executed on any thread, it's
recommended to use ConfigureAwait(false) to avoid unnecessary context
switching and potential deadlocks.
2018-06-21 19:28:27 -07:00
Kenneth Skovhede be6093b7a6 Fixed unecrypted temporary files stored for upload were not removed. 2018-06-20 10:11:56 +02:00
Kenneth Skovhede 729baf76e6 Fixed registering the newly created index volume after upload has completed 2018-06-13 21:43:06 +02:00
Kenneth Skovhede bce1db123a Merge branch 'master' into feature/speedup_backup_index_files
# Conflicts:
#	Duplicati/Library/Utility/Utility.cs
2018-06-08 10:31:27 +02:00
Kenneth Skovhede d042e70ca2 Changed the returned IEnumerable values to be fully created, which avoids issues with locks and transactions being prematurely released.
This might help with #3202
2018-06-04 11:56:54 +02:00
Kenneth Hsu f12858e6a5 Mark fields that shouldn't be reassigned as readonly.
This makes it explicit at compile-time that these fields should not be
reassigned outside the constructor.
2018-05-25 10:04:52 -07:00
Kenneth Skovhede c50721e0c4 Added input validation to the IndexVolumeCreator to make sure it does not create invalid temporary lists 2018-05-09 17:37:30 +02:00
Kenneth Skovhede 3081447271 Added an on-the-fly index builder to avoid querying the database for each volume 2018-04-30 14:04:30 +02:00
Kenneth Skovhede 79f7b22e0f Merge branch 'master' into concurrent_processing
Changed a few things on the way, removing the log process

# Conflicts:
#	Duplicati/Library/Main/Controller.cs
#	Duplicati/Library/Main/Database/ExtensionMethods.cs
#	Duplicati/Library/Main/Database/LocalBackupDatabase.cs
#	Duplicati/Library/Main/Duplicati.Library.Main.csproj
#	Duplicati/Library/Main/Operation/BackupHandler.cs
#	Duplicati/Library/Main/Operation/FilelistProcessor.cs
#	Duplicati/Library/Main/Operation/PurgeBrokenFilesHandler.cs
#	Duplicati/Library/Main/Operation/TestFilterHandler.cs
#	Duplicati/Library/Main/Options.cs
#	Duplicati/Library/Main/ResultClasses.cs
#	Duplicati/UnitTest/BasicSetupHelper.cs
2018-04-11 23:02:47 +02:00
Kenneth Skovhede 75bf6857c1 Merge branch 'master' into concurrent_processing
# Conflicts:
#	.travis.yml
#	Duplicati/Library/Main/Database/LocalBackupDatabase.cs
#	Duplicati/Library/Main/Operation/BackupHandler.cs
#	Duplicati/Library/Main/ResultClasses.cs
#	Duplicati/Library/Main/Volumes/VolumeWriterBase.cs
#	Duplicati/Library/Utility/TempFile.cs
2018-01-20 15:02:41 +01:00
Kenneth Skovhede 860924bb62 Updated main functions to new CoCoL library 2017-09-20 21:03:24 +02:00
Kenneth Skovhede 683b04741d Merge branch 'master' into concurrent_processing
# Conflicts:
#	Duplicati/Library/Main/Operation/BackupHandler.cs

Manually fixed the HashAlgorithmHelper case
2017-09-20 13:56:37 +02:00
Kenneth Skovhede bc6e32d049 Updated the new backend handler to support the same features as the previous: throttle, error message, and deleteGraceTime. 2017-09-19 14:24:59 +02:00
Kenneth Skovhede 21b7a98dc3 Implemented the blocking flag in the uploader 2017-09-19 14:18:54 +02:00
Kenneth Skovhede 14f1c58c64 Improved shutdown to avoid exceptions being masked by errors that occur during shutdown 2016-04-06 21:16:34 +02:00
Kenneth Skovhede 850c8e432b Fixed a spelling error 2016-03-14 09:38:19 +01:00
Kenneth Skovhede a3f2b39d23 Implemented handling of pause/stop/abort in the concurrent code.
Implemented the dry-run feature for backups.
2016-02-29 21:52:11 +01:00
Kenneth Skovhede 35f9a70b3d Fixed resetting the backend 2016-02-25 23:33:55 +01:00