mirror of
https://github.com/duplicati/duplicati.git
synced 2025-11-28 03:20:25 +08:00
This PR adds detection of the MacOS Photos folder, and intercepts reads and replaces them with PhotoKit calls. With this, it is possible to make backups of all MacOS Photos, even if they are not stored locally. The previous versions would just make a backup of the on-disk structure, which was not guaranteed to contain all photos, but instead has various indexing for finding photos, and may contain some original photos. The option `--photos-handling` controls how Duplicati now deals with the Photos folder. The options are: - `LibraryOnly`: Same as before, just treat it as a folder - `PhotosOnly`: Ignore the folder contents and just back up the actual photos - `PhotosAndLibrary` (default): Make a backup of the photos and the library on-disk. This may cause images to be stored twice, but de-duplication will usually limit the storage increase. The option `--photos-library-path` can be used to point to the on-disk Photo library that should be handled, in case the auto-detection does not pick it up. If this does not point to a valid Photoslibrary, or the path is not being backed up, no special handling will be done. Note that the restore is not restoring into Photos itself, but instead restores into a sub-folder in the Photolibrary that is called `dup_backup`. To get the photos out after a restore, one needs to right-click the Photolibrary folder, and choose "Show package contents" and then the `dup_backup` folder is revealed. This is done to keep all photos in the same folder, but avoid messing with the structure of the on-disk Photolibrary. A future update could allow restoring back into Photos, and metadata is captured for each image to eventually allow this. This fixes #6381
48 lines
2.4 KiB
C#
48 lines
2.4 KiB
C#
// Copyright (C) 2025, The Duplicati Team
|
|
// https://duplicati.com, hello@duplicati.com
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
// to deal in the Software without restriction, including without limitation
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
#nullable enable
|
|
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.Versioning;
|
|
using Duplicati.Library.Interface;
|
|
using Duplicati.Library.Snapshots.MacOS;
|
|
|
|
namespace Duplicati.Library.Snapshots
|
|
{
|
|
/// <summary>
|
|
/// Handler for providing a snapshot like access to files and folders
|
|
/// </summary>
|
|
/// <param name="sources">The list of source paths</param>
|
|
/// <param name="ignoreAdvisoryLocks">Whether to ignore advisory locks</param
|
|
/// <param name="followSymlinks">Whether to follow symlinks</param>
|
|
/// <param name="photosLibraryPath">The user specified MacOS Photos library path</param>
|
|
[SupportedOSPlatform("macOS")]
|
|
public sealed class NoSnapshotMacOS(IEnumerable<string> sources, bool ignoreAdvisoryLocks, bool followSymlinks, MacOSPhotosHandling macOSPhotosHandling, string? photosLibraryPath)
|
|
: NoSnapshotLinux(sources, ignoreAdvisoryLocks, followSymlinks)
|
|
{
|
|
/// <inheritdoc/>
|
|
public override IEnumerable<ISourceProviderEntry> EnumerateFilesystemEntries(ISourceProviderEntry source)
|
|
=> base.EnumerateFilesystemEntries(source).Select(b => MacOS.MacOSPhotosLibrary.TryWrap(b, macOSPhotosHandling, photosLibraryPath));
|
|
}
|
|
}
|
|
|