Merge pull request #6769 from duplicati/feature/nullable-warnings-fix
Fixed a few nullable warnings
This commit is contained in:
@@ -116,7 +116,7 @@ namespace Duplicati.Library.AutoUpdater
|
||||
static UpdaterManager()
|
||||
{
|
||||
// Set the installation path
|
||||
INSTALLATIONDIR = Util.AppendDirSeparator(Path.GetDirectoryName(Utility.Utility.getEntryAssembly().Location));
|
||||
INSTALLATIONDIR = Util.AppendDirSeparator(Path.GetDirectoryName(Utility.Utility.getEntryAssembly().Location) ?? "");
|
||||
|
||||
// Attempt to read the installed manifest file
|
||||
UpdateInfo? selfVersion = null;
|
||||
|
||||
@@ -862,7 +862,7 @@ namespace Duplicati.Library.Main.Database
|
||||
ELSE ""Path""
|
||||
END
|
||||
")
|
||||
.SetParameterValue("@Path", Util.AppendDirSeparator(System.IO.Path.GetPathRoot(Library.Utility.TempFolder.SystemTempPath)).Replace("\\", "/"))
|
||||
.SetParameterValue("@Path", Util.AppendDirSeparator(System.IO.Path.GetPathRoot(Library.Utility.TempFolder.SystemTempPath) ?? "").Replace("\\", "/"))
|
||||
.ExecuteNonQueryAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public class FileRestoreDestinationProvider(string mountedPath, bool allowRestor
|
||||
var targetpath = isDirTarget ? path.Substring(0, path.Length - 1) : path;
|
||||
|
||||
// Make the symlink first, otherwise we cannot apply metadata to it
|
||||
if (metadata.TryGetValue("CoreSymlinkTarget", out var k))
|
||||
if (metadata.TryGetValue("CoreSymlinkTarget", out var k) && !string.IsNullOrWhiteSpace(k))
|
||||
{
|
||||
if (!allowRestoreOutsideTargetDirectory && !string.IsNullOrWhiteSpace(TargetDestination))
|
||||
{
|
||||
|
||||
@@ -623,7 +623,7 @@ public partial class RestoreProvider
|
||||
}
|
||||
|
||||
// Remove the "/content.json" suffix to get the message path so replies can find it
|
||||
var restoreMessagePath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath));
|
||||
var restoreMessagePath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath) ?? "");
|
||||
|
||||
if (!_ignoreExisting)
|
||||
{
|
||||
|
||||
@@ -256,7 +256,7 @@ public partial class RestoreProvider
|
||||
var displayName = metadata.GetValueOrDefault("o365:Name") ?? metadata.GetValueOrDefault("o365:DisplayName") ?? "Restored Section Group";
|
||||
|
||||
// Find parent
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
|
||||
string? parentId = null;
|
||||
bool isNotebookParent = false;
|
||||
@@ -310,7 +310,7 @@ public partial class RestoreProvider
|
||||
var displayName = metadata.GetValueOrDefault("o365:Name") ?? metadata.GetValueOrDefault("o365:DisplayName") ?? "Restored Section";
|
||||
|
||||
// Find parent
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
|
||||
string? parentId = null;
|
||||
bool isNotebookParent = false;
|
||||
@@ -360,7 +360,7 @@ public partial class RestoreProvider
|
||||
if (!filePath.EndsWith(".html", StringComparison.OrdinalIgnoreCase))
|
||||
continue;
|
||||
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(filePath.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(filePath.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
if (parentPath == null)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ public partial class RestoreProvider
|
||||
|
||||
while (true)
|
||||
{
|
||||
var parentDir = Util.AppendDirSeparator(Path.GetDirectoryName(currentPath.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var parentDir = Util.AppendDirSeparator(Path.GetDirectoryName(currentPath.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
if (string.IsNullOrEmpty(parentDir)) break;
|
||||
|
||||
if (_restoredSharePointListMap.TryGetValue(parentDir, out var mappedListId))
|
||||
@@ -307,7 +307,7 @@ public partial class RestoreProvider
|
||||
|
||||
// Determine parent ID
|
||||
string parentId;
|
||||
var itemParentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var itemParentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -441,7 +441,7 @@ public partial class RestoreProvider
|
||||
if (_restoredSharePointFolderMap.TryGetValue(currentPath, out var cachedId))
|
||||
return cachedId;
|
||||
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(currentPath.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(currentPath.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
|
||||
// Safety check to prevent infinite recursion if we go above listPath
|
||||
if (string.IsNullOrEmpty(parentPath) || currentPath.Length <= listPath.Length)
|
||||
|
||||
@@ -138,7 +138,7 @@ public partial class RestoreProvider
|
||||
var originalPath = task.Key;
|
||||
|
||||
// Find parent list
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
if (parentPath == null || !_restoredTaskListMap.TryGetValue(parentPath, out var listId))
|
||||
{
|
||||
Log.WriteWarningMessage(LOGTAG, "RestoreTaskListTasksMissingParent", null, $"Could not find parent list for task {originalPath}, skipping.");
|
||||
@@ -213,7 +213,7 @@ public partial class RestoreProvider
|
||||
var parentDir = Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)); // ChecklistItems
|
||||
if (parentDir == null) continue;
|
||||
|
||||
var taskPath = Util.AppendDirSeparator(Path.GetDirectoryName(parentDir)); // TaskId
|
||||
var taskPath = Util.AppendDirSeparator(Path.GetDirectoryName(parentDir) ?? ""); // TaskId
|
||||
|
||||
if (taskPath == null || !_restoredTaskMap.TryGetValue(taskPath, out var taskId))
|
||||
{
|
||||
@@ -227,7 +227,7 @@ public partial class RestoreProvider
|
||||
var tasksDir = Path.GetDirectoryName(taskPath.TrimEnd(Path.DirectorySeparatorChar)); // Tasks
|
||||
if (tasksDir == null) continue;
|
||||
|
||||
var listPath = Util.AppendDirSeparator(Path.GetDirectoryName(tasksDir)); // ListId
|
||||
var listPath = Util.AppendDirSeparator(Path.GetDirectoryName(tasksDir) ?? ""); // ListId
|
||||
|
||||
if (listPath == null || !_restoredTaskListMap.TryGetValue(listPath, out var listId))
|
||||
{
|
||||
@@ -273,7 +273,7 @@ public partial class RestoreProvider
|
||||
var parentDir = Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)); // LinkedResources
|
||||
if (parentDir == null) continue;
|
||||
|
||||
var taskPath = Util.AppendDirSeparator(Path.GetDirectoryName(parentDir)); // TaskId
|
||||
var taskPath = Util.AppendDirSeparator(Path.GetDirectoryName(parentDir) ?? ""); // TaskId
|
||||
|
||||
if (taskPath == null || !_restoredTaskMap.TryGetValue(taskPath, out var taskId))
|
||||
{
|
||||
@@ -285,7 +285,7 @@ public partial class RestoreProvider
|
||||
var tasksDir = Path.GetDirectoryName(taskPath.TrimEnd(Path.DirectorySeparatorChar)); // Tasks
|
||||
if (tasksDir == null) continue;
|
||||
|
||||
var listPath = Util.AppendDirSeparator(Path.GetDirectoryName(tasksDir)); // ListId
|
||||
var listPath = Util.AppendDirSeparator(Path.GetDirectoryName(tasksDir) ?? ""); // ListId
|
||||
|
||||
if (listPath == null || !_restoredTaskListMap.TryGetValue(listPath, out var listId))
|
||||
{
|
||||
|
||||
@@ -878,7 +878,7 @@ public partial class RestoreProvider : IRestoreDestinationProviderModule
|
||||
// Determine parent folder ID
|
||||
// We assume the path structure reflects the hierarchy
|
||||
// If parent path is not in map, we assume it's the root (mailboxId)
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
var parentId = mailboxId;
|
||||
|
||||
if (parentPath != null && _restoredEmailFolderMap.TryGetValue(parentPath, out var mappedParentId))
|
||||
@@ -939,7 +939,7 @@ public partial class RestoreProvider : IRestoreDestinationProviderModule
|
||||
|
||||
// Determine target folder
|
||||
var targetFolderId = mailboxId;
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(emailSource.Key.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(emailSource.Key.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
if (parentPath != null && _restoredEmailFolderMap.TryGetValue(parentPath, out var mappedFolderId))
|
||||
{
|
||||
targetFolderId = mappedFolderId;
|
||||
@@ -1068,7 +1068,7 @@ public partial class RestoreProvider : IRestoreDestinationProviderModule
|
||||
var restoreTarget = await DriveRestore.GetDefaultDriveAndFolder(cancel);
|
||||
if (!string.IsNullOrWhiteSpace(restoreTarget.FolderId))
|
||||
{
|
||||
var rootFolderPath = Util.AppendDirSeparator(Path.GetDirectoryName(sortedFolders.First().Key.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var rootFolderPath = Util.AppendDirSeparator(Path.GetDirectoryName(sortedFolders.First().Key.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
_restoredDriveFolderMap.AddOrUpdate(rootFolderPath, restoreTarget.FolderId, (k, v) => v);
|
||||
}
|
||||
|
||||
@@ -1115,7 +1115,7 @@ public partial class RestoreProvider : IRestoreDestinationProviderModule
|
||||
}
|
||||
|
||||
// Determine parent folder ID
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
var parentId = defaultRootId;
|
||||
|
||||
if (parentPath != null && (drivePath == null || parentPath.TrimEnd(Path.DirectorySeparatorChar) != drivePath.TrimEnd(Path.DirectorySeparatorChar)))
|
||||
@@ -1217,7 +1217,7 @@ public partial class RestoreProvider : IRestoreDestinationProviderModule
|
||||
}
|
||||
|
||||
// Determine parent folder ID
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
var parentId = defaultRootId;
|
||||
|
||||
if (parentPath != null && (drivePath == null || parentPath.TrimEnd(Path.DirectorySeparatorChar) != drivePath.TrimEnd(Path.DirectorySeparatorChar)))
|
||||
@@ -1354,7 +1354,7 @@ public partial class RestoreProvider : IRestoreDestinationProviderModule
|
||||
|
||||
// Group attachments by event path
|
||||
var attachments = GetMetadataByType(SourceItemType.CalendarEventAttachment)
|
||||
.GroupBy(k => Util.AppendDirSeparator(Path.GetDirectoryName(k.Key.TrimEnd(Path.DirectorySeparatorChar))))
|
||||
.GroupBy(k => Util.AppendDirSeparator(Path.GetDirectoryName(k.Key.TrimEnd(Path.DirectorySeparatorChar)) ?? ""))
|
||||
.ToDictionary(g => g.Key, g => g.ToList());
|
||||
|
||||
var singles = new List<(string Path, GraphEvent Event)>();
|
||||
@@ -1612,7 +1612,7 @@ public partial class RestoreProvider : IRestoreDestinationProviderModule
|
||||
}
|
||||
|
||||
// Determine parent folder ID
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
var parentId = defaultFolderId;
|
||||
|
||||
if (parentPath != null && _restoredContactFolderMap.TryGetValue(parentPath, out var mappedParentId))
|
||||
@@ -1672,7 +1672,7 @@ public partial class RestoreProvider : IRestoreDestinationProviderModule
|
||||
|
||||
// Determine target folder
|
||||
var targetFolderId = defaultFolderId;
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
if (parentPath != null && _restoredContactFolderMap.TryGetValue(parentPath, out var mappedFolderId))
|
||||
{
|
||||
targetFolderId = mappedFolderId;
|
||||
@@ -1779,7 +1779,7 @@ public partial class RestoreProvider : IRestoreDestinationProviderModule
|
||||
|
||||
// Determine target folder
|
||||
var targetFolderId = defaultFolderId;
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
var parentPath = Util.AppendDirSeparator(Path.GetDirectoryName(originalPath.TrimEnd(Path.DirectorySeparatorChar)) ?? "");
|
||||
if (parentPath != null && _restoredContactFolderMap.TryGetValue(parentPath, out var mappedFolderId))
|
||||
targetFolderId = mappedFolderId;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user