Welcome to mirror list, hosted at ThFree Co, Russian Federation.

StorjFile.cs « Storj « Backend « Library « Duplicati - github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 626e25397289379ff56b526f9dad0b7b7e95225c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using Duplicati.Library.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Duplicati.Library.Backend.Storj
{
    public class StorjFile : IFileEntry
    {
        public static readonly string STORJ_LAST_ACCESS = "DUPLICATI:LAST-ACCESS";
        public static readonly string STORJ_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 StorjFile()
        {

        }

        public StorjFile(uplink.NET.Models.Object tardigradeObject)
        {
            IsFolder = tardigradeObject.IsPrefix;
            var lastAccess = tardigradeObject.CustomMetaData.Entries.Where(e => e.Key == STORJ_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 == STORJ_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;
        }
    }
}