Files
duplicati/Duplicati.Library.Backend.Tardigrade/TardigradeFile.cs
T
2020-05-07 22:22:34 +02:00

49 lines
1.6 KiB
C#

using Duplicati.Library.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Duplicati.Library.Backend.Tardigrade
{
public class TardigradeFile : IFileEntry
{
public const string TARDIGRADE_LAST_ACCESS = "DUPLICATI:LAST-ACCESS";
public const string TARDIGRADE_LAST_MODIFICATION = "DUPLICATI:LAST-MODIFICATION";
public bool IsFolder { get; set; }
public DateTime LastAccess { get; set; }
public DateTime LastModification { get; set; }
public string Name { get; set; }
public long Size { get; set; }
public TardigradeFile()
{
}
public TardigradeFile(uplink.NET.Models.Object tardigradeObject)
{
IsFolder = tardigradeObject.IsPrefix;
var lastAccess = tardigradeObject.CustomMetaData.Entries.Where(e => e.Key == TARDIGRADE_LAST_ACCESS).FirstOrDefault();
if (lastAccess != null && !string.IsNullOrEmpty(lastAccess.Value))
LastAccess = DateTime.Parse(lastAccess.Value);
else
LastAccess = DateTime.MinValue;
var lastMod = tardigradeObject.CustomMetaData.Entries.Where(e => e.Key == TARDIGRADE_LAST_MODIFICATION).FirstOrDefault();
if (lastMod != null && !string.IsNullOrEmpty(lastMod.Value))
LastModification = DateTime.Parse(lastMod.Value);
else
LastModification = DateTime.MinValue;
Name = tardigradeObject.Key;
Size = tardigradeObject.SystemMetaData.ContentLength;
}
}
}