Commit Graph
54 Commits
Author SHA1 Message Date
Kenneth Skovhede 0a7a1cd689 Added option to set the SQLite page cache
This adds an extra option to allow setting the SQLite page cache size as a regular option.

Prior to this commit it was only possible to set the SQLite page cache size via environment variables.

The option to use environment variables is preserved, and as options from the environment variable are applied after the new setting, environment variables take precedence.

The default value for the new option is to use 1% of the system memory for the page cache. For the restore process, a connection per worker may be made which defaults to half the number of cores, so the maximum amount of memory is 1% * half the CPU cores.

This is just the upper limit, and SQLite may choose not to use all of it.

This fixes #6178
2025-04-22 14:26:46 +02:00
Kenneth Skovhede 0b735d79ff More cleanup and a few bug fixes 2025-04-03 16:38:51 +02:00
Kenneth Skovhede e2df06b8f5 Guards for setting permissions
When setting the permissions, this does not crash the process if it fails, but emits a warning.
2025-03-31 16:07:50 +02:00
Kenneth Skovhede d8a15ac7ed Fixed review comments 2025-03-20 12:05:16 +01:00
Kenneth Skovhede fbe79b1ca3 Improve SQLite loading
This commit changes the way the new restore flow loads the extra database connections so these will also apply the temporary folder settings and custom pragmas.

This also changes the logic around the SQLite temporary folder. Previously, this folder would unconditionally be set to the general temporary folder, allowing only an override with a custom pragma.

No the setup checks if the system has the environment variable `SQLITE_TMPDIR` set already. If this variable is already set, it will NOT be overwritten.
Actual effects of this change depends on how SQLite internally resolves the temporary folder.
2025-03-20 10:05:10 +01:00
Kenneth Skovhede fef0431144 Honor insecure permissions.
This commit changes the logic so permissions are only set on files, if the `insecure-permissions.txt` file is not found in the folder.

Prior to this commit, new files would be locked down without condition.
2025-03-19 21:20:07 +01:00
Kenneth Skovhede f0f79418d8 Fixed logic so the permissions are always applied, unless the user specifically opts out by placing a file named insecure-permissions.txt in the data folder. 2025-02-06 17:09:18 +01:00
Kenneth Skovhede aab91eb0df Added protection to newly create data folder and databases 2025-02-06 16:56:06 +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 fdc891aa36 Merge pull request #5208 from Jojo-1000/fix-sql-quotes
Fix SQL string quotes
2024-06-04 20:58:20 +02:00
Jojo-1000 a5c6c18f26 Prevent SQLite crash on MacOS. 2024-06-04 19:35:06 +02:00
Jojo-1000 930f1c8bd3 Fix most unsupported platform warnings. 2024-05-30 01:50:02 +02:00
Jojo-1000 1dc1fd83af Add SupportedOSPlatform attribute and target windows where appropriate. 2024-05-30 01:22:16 +02:00
Jojo-1000 2ecfde44f9 Disable double quoted sql string compatibility mode. 2024-05-30 00:00:49 +02:00
Kenneth Skovhede 1265f88cf8 Fixed disposing the read stream before moving the encrypted database.
Added more context to the default error message when decryption fails.
2024-05-08 12:48:10 +02:00
Kenneth Skovhede 612f657614 Added nullable to SQLiteLoader.
Avoid checking file if no password is supplied.
2024-04-24 11:16:11 +02:00
Kenneth Skovhede 9c0ef09a39 Implemented a built-in decrypt method.
Ported the RC4 algorithm from BouncyCastle.
This fixes #5147
2024-04-23 17:06:32 +02:00
Kenneth Skovhede 9377fdffc1 Unified the way the version is extracted from the SQLite library 2024-03-05 08:55:13 +01:00
Kenneth Skovhede 473c6cbbb8 Merge commit '4f577c65a4d8806f79637c50c21ca3a683c5a07a' into feature/kestrel-avalonia-upgrade 2024-03-04 12:21:53 +01:00
Kenneth Skovhede d3d4fc1434 More cleanup after using Mono.Posix 2024-03-01 14:30:28 +01:00
Thomas Suckow a3bbf63561 Merge remote-tracking branch 'origin/feature/upgrade-to-sdk-style-projects' into feature/net5-kestrel
# Conflicts:
#	.appveyor.yml
#	.github/workflows/tests.yml
#	BuildTools/AutoUpdateBuilder/AutoUpdateBuilder.csproj
#	BuildTools/DependencyFinder/DependencyFinder.csproj
#	BuildTools/GnupgSigningTool/GnupgSigningTool.csproj
#	BuildTools/UpdateVersionStamp/UpdateVersionStamp.csproj
#	Duplicati CommandLine Only.sln
#	Duplicati.Library.RestAPI/RESTMethods/RequestInfo.cs
#	Duplicati.Library.RestAPI/Runner.cs
#	Duplicati.sln
#	Duplicati/CommandLine/BackendTester/Duplicati.CommandLine.BackendTester.csproj
#	Duplicati/CommandLine/BackendTester/app.config
#	Duplicati/CommandLine/BackendTool/Duplicati.CommandLine.BackendTool.csproj
#	Duplicati/CommandLine/BackendTool/app.config
#	Duplicati/CommandLine/ConfigurationImporter/Duplicati.CommandLine.ConfigurationImporter.csproj
#	Duplicati/CommandLine/Duplicati.CommandLine.csproj
#	Duplicati/CommandLine/RecoveryTool/Duplicati.CommandLine.RecoveryTool.csproj
#	Duplicati/CommandLine/app.config
#	Duplicati/GUI/Duplicati.GUI.TrayIcon/Assets/icons/normal-warning.png
#	Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj
#	Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs
#	Duplicati/GUI/Duplicati.GUI.TrayIcon/app.config
#	Duplicati/Library/AutoUpdater/Duplicati.Library.AutoUpdater.csproj
#	Duplicati/Library/Backend/AlternativeFTP/Duplicati.Library.Backend.AlternativeFTP.csproj
#	Duplicati/Library/Backend/AzureBlob/Duplicati.Library.Backend.AzureBlob.csproj
#	Duplicati/Library/Backend/Backblaze/Duplicati.Library.Backend.Backblaze.csproj
#	Duplicati/Library/Backend/Box/Duplicati.Library.Backend.Box.csproj
#	Duplicati/Library/Backend/CloudFiles/Duplicati.Library.Backend.CloudFiles.csproj
#	Duplicati/Library/Backend/Dropbox/Duplicati.Library.Backend.Dropbox.csproj
#	Duplicati/Library/Backend/FTP/Duplicati.Library.Backend.FTP.csproj
#	Duplicati/Library/Backend/File/Duplicati.Library.Backend.File.csproj
#	Duplicati/Library/Backend/GoogleServices/Duplicati.Library.Backend.GoogleServices.csproj
#	Duplicati/Library/Backend/HubiC/Duplicati.Library.Backend.HubiC.csproj
#	Duplicati/Library/Backend/Idrivee2/Duplicati.Library.Backend.Idrivee2.csproj
#	Duplicati/Library/Backend/Jottacloud/Duplicati.Library.Backend.Jottacloud.csproj
#	Duplicati/Library/Backend/Mega/Duplicati.Library.Backend.Mega.csproj
#	Duplicati/Library/Backend/OAuthHelper/Duplicati.Library.OAuthHelper.csproj
#	Duplicati/Library/Backend/OneDrive/Duplicati.Library.Backend.OneDrive.csproj
#	Duplicati/Library/Backend/OpenStack/Duplicati.Library.Backend.OpenStack.csproj
#	Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone.csproj
#	Duplicati/Library/Backend/S3/Duplicati.Library.Backend.S3.csproj
#	Duplicati/Library/Backend/SSHv2/Duplicati.Library.Backend.SSHv2.csproj
#	Duplicati/Library/Backend/SharePoint/Duplicati.Library.Backend.SharePoint.csproj
#	Duplicati/Library/Backend/Sia/Duplicati.Library.Backend.Sia.csproj
#	Duplicati/Library/Backend/Storj/Duplicati.Library.Backend.Storj.csproj
#	Duplicati/Library/Backend/TahoeLAFS/Duplicati.Library.Backend.TahoeLAFS.csproj
#	Duplicati/Library/Backend/Tardigrade/Duplicati.Library.Backend.Tardigrade.csproj
#	Duplicati/Library/Backend/TencentCOS/Duplicati.Library.Backend.TencentCOS.csproj
#	Duplicati/Library/Backend/WEBDAV/Duplicati.Library.Backend.WEBDAV.csproj
#	Duplicati/Library/Common/Duplicati.Library.Common.csproj
#	Duplicati/Library/Compression/Duplicati.Library.Compression.csproj
#	Duplicati/Library/DynamicLoader/Duplicati.Library.DynamicLoader.csproj
#	Duplicati/Library/Encryption/Duplicati.Library.Encryption.csproj
#	Duplicati/Library/Interface/Duplicati.Library.Interface.csproj
#	Duplicati/Library/Localization/Duplicati.Library.Localization.csproj
#	Duplicati/Library/Logging/Duplicati.Library.Logging.csproj
#	Duplicati/Library/Main/Duplicati.Library.Main.csproj
#	Duplicati/Library/Modules/Builtin/CheckMonoSSL.cs
#	Duplicati/Library/Modules/Builtin/Duplicati.Library.Modules.Builtin.csproj
#	Duplicati/Library/Modules/Builtin/SendJabberMessage.cs
#	Duplicati/Library/SQLiteHelper/Duplicati.Library.SQLiteHelper.csproj
#	Duplicati/Library/Snapshots/Duplicati.Library.Snapshots.csproj
#	Duplicati/Library/UsageReporter/Duplicati.Library.UsageReporter.csproj
#	Duplicati/Library/Utility/Duplicati.Library.Utility.csproj
#	Duplicati/Library/Utility/HashAlgorithmHelper.cs
#	Duplicati/Library/Utility/Power/WindowsPowerSupplyState.cs
#	Duplicati/License/Duplicati.License.csproj
#	Duplicati/Server/Duplicati.Server.Serialization/Duplicati.Server.Serialization.csproj
#	Duplicati/Server/Duplicati.Server.csproj
#	Duplicati/Server/app.config
#	Duplicati/Service/Duplicati.Service.csproj
#	Duplicati/Service/app.config
#	Duplicati/Tools/Duplicati.Tools.csproj
#	Duplicati/UnitTest/Duplicati.UnitTest.csproj
#	Duplicati/UnitTest/GeneralBlackBoxTesting.cs
#	Duplicati/UnitTest/app.config
#	Duplicati/WindowsService/WindowsService.csproj
#	Installer/debian/docker/debian/control
#	Tools/SQLiteTool/SQLiteTool.csproj
#	Tools/ZipFileDebugger/ZipFileDebugger.csproj
#	guiTests/guiTest.py
#	thirdparty/UnixSupport/UnixSupport.csproj
#	thirdparty/alphavss/Homepage.txt
#	thirdparty/alphavss/License.txt
#	thirdparty/alphavss/licensedata.json
2024-02-29 21:55:17 -08:00
Kenneth Skovhede 40dd3c6816 Updated all license mentions to MIT 2024-02-28 15:45:30 +01:00
gpatel-fr fbbc78619e add custom sqlite pragmas
through environment variable CUSTOMSQLITEOPTIONS_DUPLICATI
2023-03-23 20:25:18 +01:00
Thomas SuckowandKenneth Hsu 060b4886da Just use the nuget version of the sqlite library
This fixes #4526.
2021-06-28 09:52:13 -07:00
Kenneth Hsu 0a91bcf662 Fix path to SQLite.Interop.dll.
This assembly lives in the win32 and win64 subdirectories, and not in
the base path.

This fixes #4093.
2020-02-17 09:34:39 -08:00
verhoek 8bb406cd15 Migrated to use the platform class. 2018-11-02 22:17:16 +01:00
Kenneth Hsu 9e0b031fee Remove unused members. 2018-10-15 21:20:30 -07:00
Kenneth Skovhede 8a00ce5c80 Merge branch 'verhoek-fix/sqlite_file_permissions'
# Conflicts:
#	Duplicati/Library/SQLiteHelper/SQLiteLoader.cs
2018-06-28 10:50:17 +02:00
Kenneth Skovhede db222c1991 Now getting the correct UID and GID 2018-06-28 09:28:14 +02:00
Kenneth Skovhede 5405139729 Replaced compile-time flag and dependency on Mono.Posix with a dynamic call to UnixSupport to defer loading the Mono.Posix library. 2018-06-27 13:36:08 +02:00
verhoek fc5f582800 moved dll filename var to const. Only change permissions on new file creation. 2018-06-23 19:16:12 +02:00
verhoek eabb840a4c Only add mono.posix on non-windows. 2018-06-22 17:21:28 +02:00
verhoek edc866c17e Make Codacy happier. 2018-06-22 09:47:46 +02:00
verhoek 05b2483b4c Added chmoding of sqlite files after opening by sqlite. Removal of some duplication. 2018-06-21 18:58:55 +02:00
verhoek 772eb1f187 Moved method to sqlite loader. 2018-06-21 18:08:52 +02:00
verhoek a456318d86 Undo of restoring TEMP/TMP environment variables. 2018-06-19 08:41:07 +02:00
verhoek 19132abd5f Check mixed mode assembly more explicitly. 2018-06-14 22:00:59 +02:00
verhoek 1cb13cc3cb Reduce indentation. 2018-06-14 21:43:20 +02:00
verhoek 98a4d4c247 Readded environment variables for SQLite on windows. 2018-06-14 21:35:21 +02:00
verhoek 7f06db8e44 Removed non-thread safe PRAGMA temp_store_directory command. 2018-06-11 22:06:06 +02:00
verhoek 544b89b3e2 Removed unused imports. 2018-06-11 19:10:41 +02:00
verhoek e51584e03f Added some logging in case of error. 2018-06-11 19:10:14 +02:00
verhoek fecd5163e5 Single responsibility applied. 2018-06-11 18:50:11 +02:00
verhoek d53a806e04 Removal of obsolete prev variable. 2018-06-11 18:31:39 +02:00
verhoek 784480a340 Removed tempdir environment variable.
Removed unused optional parameter for tempdir in LoadConnection for
LoadConnection and hence avoiding restoring never changed SQLITE_TMPDIR
vars.
2018-06-11 14:40:57 +02:00
Kenneth Skovhede ee64517f7d Removed calls to Console.WriteLine as we may run somewhere without a console. 2018-05-15 11:29:08 +02:00
Kenneth Hsu 056ff3da96 Use built-in method to determine if process is 64-bit. 2018-01-02 19:03:46 -08:00
Kenneth Skovhede f223c38ad7 Updating the SQLite library on Windows to 1.0.104.0.
The Linux version use Mono.Data.SQLite if possible, and otherwise attempts to wrap the system sqlite.so.

This fixes #2144
2017-03-01 11:10:01 +01:00
Kenneth Skovhede c79eaad6a8 Pedantic fix: use single quotes as described in the documentation 2017-01-16 10:28:38 +01:00
Kenneth Skovhede 3b4cd3c9c2 Experiment to set the SQLite temp folder, both through the environment variable and the deprecated pragma statement 2017-01-15 23:09:47 +01:00