Commit Graph
58 Commits
Author SHA1 Message Date
Kenneth Skovhede 7031bc57b6 Adding ConfigureAwait(false) to all async enumerations 2025-02-18 09:18:36 +01:00
Kenneth Skovhede 0f9669b273 Final conversion to async backends
This PR is the final change, where all backends are now purely implemented with async interfaces.

The code changes here replace the LIST call with an async version. This affect all backends (and then some) but the changes are mostly mechanical rewrites of the code.

In many places, the backeds were already prepared for async output, in other some glue was needed.

To reduce the scope of this change, some backends simply report a synchronous result as an async list.
2025-02-17 16:45:51 +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 0023dfd19f Removed the use of WebClient in MicrosoftGraphBackend in favor of HttpClient. (#5799) 2024-12-19 22:40:18 +01:00
Kenneth SkovhedeandGitHub 86f3f6b178 Fixed issues with timeout in msgraph (#5790)
* Fixed issues with timeout in msgraph

Fixed a place where the cancellation token was not applied.

Fixed a problem with msgraph not sending correct DNS information.

Fixed a problem with msgraph downloading the entire file before streaming it, bypassing throttle and tripping the timeout.

Added `ITimeoutExemptBackend` to selectively disable timeouts for backends that do not support it.

Updated the backendmanager to support `ITimeoutExemptBackend`.

Updated the backendmanager to abort as soon as a timeout happens.

* Updated BackendTester to use the `TimeoutObservingStream` and support the `--read-write-timeout` setting.

Updated backend tester code to use `var`

* Fixed a bug reading the `read-write-timeout`

* Updated to using constants with names instead of `-1`.
2024-12-19 09:31:06 +01:00
Kenneth Skovhede e62f1639b3 Implemented a way to share retry timeouts between multiple instances of the same backend. 2024-11-01 09:20:11 +01:00
Kenneth Skovhede 61ea36091a Added DNSNames as async 2024-10-02 09:37:52 +02:00
Kenneth Skovhede 586c08522e Implemented async method for Test, CreateFolder and Quota in all backends.
Still missing the List and DNSHostnames.
The AsyncRequest class is also preventing many backends from fully upgrading.
2024-10-01 09:30:02 +02:00
Kenneth Skovhede 8bdb85e261 Implemented RenameAsync on all backends supporting rename 2024-09-29 23:21:50 +02:00
Kenneth Skovhede ecf2e8b551 Implemented DeleteAsync on all backends 2024-09-29 23:04:54 +02:00
Kenneth Skovhede e3e3d1305f Implemented async version of Get for all backends. 2024-09-29 22:00:57 +02:00
Suguru Hirahara ae57dee0f0 Remove redundant space characters from *.cs and *.html 2024-07-26 00:10:31 -04:00
Kenneth Skovhede a0c0cbf3d5 Removed mentions of Mono in code, and fixed some entry paths pointing to the dll instead of the exe 2024-04-15 13:20:39 +02:00
Kenneth Skovhede 40dd3c6816 Updated all license mentions to MIT 2024-02-28 15:45:30 +01:00
Tyler Gill b64c2f1df0 Move Retry-After logic to RetryAfterHelper to make it easier for other backends to incorporate it. 2021-03-23 17:28:39 -06:00
Tyler Gill dadd30380c Add some logging to Microsoft Graph backends. 2021-03-23 17:08:58 -06:00
Tyler Gill 06c28387d5 Address some more feedback 2021-03-20 16:09:23 -06:00
Tyler Gill 9a4632d551 Remove SubStream and add functionality to ReadLimitLengthStream. Switch to using that.
Also add some hardening around the Position and make sure the stream starts at relative Position 0.
2021-03-17 20:37:46 -06:00
Tyler Gill b0793d3e49 Refactor the Retry-After logic. Now it tracks Retry-After headers on all requests, and blocks any future requests until the time from the prior request has passed. 2021-03-16 11:40:38 -06:00
Tyler Gill 7894152489 A few more improvements to the MicrosoftGraphBackends.
First, when performing an upload using an upload session, data is streamed directly from the input stream to the request stream. (It is no longer read into an intermediate buffer first.)
Hopefully this will help these uploads respond to throttling behavior better.
Second, these backends now check for and respect a Retry-After header if it is present.
On 5xx errors, the existing exponential backoff is used for the intermediate retries.
A few other minor things have also been cleaned up (e.g., using Task.Delay instead of Thread.Sleep)
2021-03-15 18:04:39 -06:00
Tyler Gill e742205f65 Add --use-http-client=false parameter to backends based on Microsoft Graph APIs (OneDrive v2, SharePoint v2, etc.) to make them use the OAuthHelper and HttpWebRequest infra used by most / all other backends for HTTP requests. This lives in parallel to the original implementation that uses the OAuthHttpClient class, but is intended to see if this prevents the memory leaks and problems seen in some versions of Mono when using the OneDrive v2 backend. 2020-03-23 14:10:40 -06:00
Kenneth Hsu 48444782c2 Fix regression with SharePoint backend.
In pull request #3989, we set the conflict resolution behavior for
creating new items to be "Replace".  While this worked for OneDrive,
SharePoint apparently is case-sensitive and expects "replace".  Since
the default behavior is to replace, we will simply remove the
specification to avoid possible conflicts.

See the forum discussion below:

https://forum.duplicati.com/t/bad-request-error-from-request-nameconflictbehavior-must-be-fail-replace-or-rename/8578
2019-12-07 12:19:21 -08:00
Tyler Gill 5364345edd Add ConfigureAwait(false) to MSGraph backends' awaits. 2019-11-14 07:51:49 -07:00
Tyler Gill e9543142f2 Explicitly dispose request messages, request contents, and response messages 2019-11-13 12:18:19 -07:00
Kenneth Hsu 988c445233 Provide cancellation token to async methods. 2019-05-26 14:55:31 -07:00
Sean Templeton b02b19e683 Change Put method name to PutAsync 2019-03-17 18:28:45 -05:00
Sean Templeton 8bd4b825c8 Fix several Codacy issues 2019-03-13 21:51:05 -05:00
Sean Templeton 13f83a22a1 Update Mega, OneDrive, and Rclone backends for async Put 2019-03-05 21:25:29 -06:00
Sean Templeton 0c122ff550 Change IBackend and IStreamingBackend to return Task for Put() 2019-03-03 21:43:10 -06:00
verhoek b2cc18426c Renamed Library.IO to Library.Common.IO.
Moved basic Platform functions to Library.Common.Platform.
Turned IO_OS into property within Library.Common.
2018-11-02 21:34:07 +01:00
verhoek 71c6aca8a7 Fixed IO calls in Filebackend.
Moved FileEntry to Library.IO due to AlphaFS not implementing
System.IO.FileInfo/DirectoryInfo.
2018-11-01 17:56:48 +01:00
Kenneth Hsu a567b467dc Fix slashes in Microsoft Graph URLs.
This fixes an issue introduced in revision f9022fec ("Avoid referencing
virtual members in constructor").

This addresses issue #3460.
2018-10-27 13:03:25 -07:00
Kenneth Hsu 8bb770964d Constrain generic type to be a class to allow for null comparison.
The SendRequest method performs a comparison between an object of type T
and null.  While there are no use cases currently where the generic type
is a value type, we should constrain the generic type to be a class so
that the comparison remains meaningful.
2018-10-08 19:13:23 -07:00
Kenneth Hsu 6c08f44394 Revert "Avoid potential comparison of value type with null."
This reverts commit ecb670a2d9.

While there aren't any cases where the generic type is a struct, the
comparison with default(T) is incorrect.  If T is int, we wouldn't want
the behavior to differ based on whether the value was zero or nonzero.
2018-10-08 18:54:36 -07:00
Kenneth Hsu ecb670a2d9 Avoid potential comparison of value type with null.
While there aren't currently any cases where the generic type is a value
type, this will make the code slightly more robust to future
implementations.
2018-10-07 09:59:13 -07:00
Kenneth Hsu e2bc85c7e4 Merge remote-tracking branch 'upstream/master' into constructor_virtual_members
Resolved Conflicts:
	Duplicati/Library/Backend/OneDrive/MicrosoftGraphBackend.cs
2018-10-01 17:15:58 -07:00
Rune HenriksenandGitHub 5f4236cbc2 Merge pull request #3399 from duplicati/remove_unused_variables_assignments
Remove unused variables, fields, and unnecessary assignments
2018-10-01 23:19:37 +02:00
Kenneth Hsu 024bc5bea2 Mark immutable field as readonly. 2018-09-30 15:45:42 -07:00
Kenneth Hsu ee14862db5 Add comment to clarify use of Lazy. 2018-09-30 15:06:55 -07:00
Kenneth Hsu f59607d94d Rename property. 2018-09-30 15:06:55 -07:00
Kenneth Hsu f9022fec66 Avoid referencing virtual members in constructor.
Since the call to GetRootPathFromUrl may be expensive, we cache the
value using a lazy initializer.
2018-09-30 15:06:49 -07:00
Kenneth Hsu 7cf830cad7 Provide protocol key to MicrosoftGraphBackend constructor.
This will help us avoid referencing virtual members in the constructor.
2018-09-30 10:59:26 -07:00
Kenneth Hsu 9ce1e807c7 Remove unused variables and fields. 2018-09-29 10:41:27 -07:00
Kenneth Hsu 44b7c29489 Rename local variable to avoid hiding class field. 2018-09-28 20:57:44 -07:00
Tyler Gill f2f5d4c0a6 Change from swallowing delete errors to wrapping DriveItemNotFoundException in FileMissingException.
This way, the regular backend manager logic can handle and log the delete of a non-existant file.
Also update some of the other operations to throw FileMissingException (rather than the backend specific DriveItemNotFoundException).
2018-06-02 15:52:20 -06:00
Tyler Gill 8131e85581 (MS Graph) When the delete operation fails due to a 'file not found' error, we don't need to bubble up an exception. 2018-05-25 09:18:20 -06:00
Tyler Gill f93f9dcc5a Add new utility class, OAuthHttpClient.
This class extends HttpClient and uses an OAuthHttpMessageHandler under the covers to automatically authenticate requests.
Additionally, it automatically respects the global HttpContextSettings for overall timeout, read/write timeout, and SSL certificate validation.
(BufferRequests isn't currently handled, as HttpClient doesn't seem to easily expose that flag, and as of .NET 4.5, seems to not buffer by default.)
2018-03-23 15:07:51 -06:00
Tyler Gill 407bead9f9 Change some fragment settings.
Default retry delay is now 1000ms, and fragment sizes must be at least the multiple size (320 KiB)
2018-03-23 15:04:23 -06:00
Tyler Gill 5bec41b665 Update both SharePoint and Office 365 group backends to support more human-discernable methods of specifying the backend destination.
For SharePoint, this means instead of giving the site ID as a parameter (and a relative path as the backup URL), the full URL to the folder in SharePoint (e.g., 'sharepoint://{tenant}.sharepoint.com/{PathToSite}/{DocumentBase}/{subfolder}') can be given, and the site ID will be looked up.
(This should match the existing SharePoint backend, including the convention of using '//' to indicate the document root, though I can't explicitly test that since the SharePoint sites I have access to require 2FA, which the old backend doesn't support.)
I've tested both explicit ID and site path methods of specifying the destination, and they appear to be working.
For Office 365 groups, it now supports looking up a group by its email address.
2018-03-22 15:20:17 -06:00
Tyler Gill 987cda7e1d When uploading large files, MS graph backends need to parse the response inside the try block for retries to work (since that is where errors are thrown) 2018-03-22 14:41:19 -06:00