root / trunk / Pithos.Core / Agents / CloudAction.cs @ 5ce54458
History | View | Annotate | Download (1.6 kB)
1 | 1caef52e | Panagiotis Kanavos | using System; |
---|---|---|---|
2 | 1caef52e | Panagiotis Kanavos | using System.IO; |
3 | 1caef52e | Panagiotis Kanavos | using System.Threading; |
4 | 1caef52e | Panagiotis Kanavos | using Pithos.Interfaces; |
5 | 1caef52e | Panagiotis Kanavos | using Pithos.Network; |
6 | 1caef52e | Panagiotis Kanavos | |
7 | 1caef52e | Panagiotis Kanavos | namespace Pithos.Core.Agents |
8 | 1caef52e | Panagiotis Kanavos | { |
9 | 1caef52e | Panagiotis Kanavos | public enum CloudActionType |
10 | 1caef52e | Panagiotis Kanavos | { |
11 | 1caef52e | Panagiotis Kanavos | MustSynch, |
12 | 1caef52e | Panagiotis Kanavos | UploadUnconditional, |
13 | 1caef52e | Panagiotis Kanavos | DownloadUnconditional, |
14 | 1caef52e | Panagiotis Kanavos | DeleteLocal, |
15 | 1caef52e | Panagiotis Kanavos | DeleteCloud, |
16 | 1caef52e | Panagiotis Kanavos | RenameCloud |
17 | 1caef52e | Panagiotis Kanavos | } |
18 | 1caef52e | Panagiotis Kanavos | |
19 | 1caef52e | Panagiotis Kanavos | public class CloudAction |
20 | 1caef52e | Panagiotis Kanavos | { |
21 | 1caef52e | Panagiotis Kanavos | public CloudActionType Action { get; set; } |
22 | 1caef52e | Panagiotis Kanavos | public FileInfo LocalFile { get; set; } |
23 | 1caef52e | Panagiotis Kanavos | public ObjectInfo CloudFile { get; set; } |
24 | 1caef52e | Panagiotis Kanavos | |
25 | 1caef52e | Panagiotis Kanavos | public Lazy<string> LocalHash { get; private set; } |
26 | 1caef52e | Panagiotis Kanavos | |
27 | 1caef52e | Panagiotis Kanavos | public string OldFileName { get; set; } |
28 | 1caef52e | Panagiotis Kanavos | public string OldPath { get; set; } |
29 | 1caef52e | Panagiotis Kanavos | public string NewFileName { get; set; } |
30 | 1caef52e | Panagiotis Kanavos | public string NewPath { get; set; } |
31 | 1caef52e | Panagiotis Kanavos | |
32 | 1caef52e | Panagiotis Kanavos | public CloudAction(CloudActionType action, string oldPath, string oldFileName, string newFileName, string newPath) |
33 | 1caef52e | Panagiotis Kanavos | { |
34 | 1caef52e | Panagiotis Kanavos | Action = action; |
35 | 1caef52e | Panagiotis Kanavos | OldFileName = oldFileName; |
36 | 1caef52e | Panagiotis Kanavos | OldPath = oldPath; |
37 | 1caef52e | Panagiotis Kanavos | NewFileName = newFileName; |
38 | 1caef52e | Panagiotis Kanavos | NewPath = newPath; |
39 | 1caef52e | Panagiotis Kanavos | LocalHash = new Lazy<string>(() => Signature.CalculateMD5(NewFileName), LazyThreadSafetyMode.ExecutionAndPublication); |
40 | 1caef52e | Panagiotis Kanavos | } |
41 | 1caef52e | Panagiotis Kanavos | |
42 | 1caef52e | Panagiotis Kanavos | public CloudAction(CloudActionType action, FileInfo localFile, ObjectInfo cloudFile) |
43 | 1caef52e | Panagiotis Kanavos | { |
44 | 1caef52e | Panagiotis Kanavos | Action = action; |
45 | 1caef52e | Panagiotis Kanavos | LocalFile = localFile; |
46 | 1caef52e | Panagiotis Kanavos | CloudFile = cloudFile; |
47 | 1caef52e | Panagiotis Kanavos | //Skip Hash calculation for folders |
48 | 1caef52e | Panagiotis Kanavos | if (LocalFile != null) |
49 | 1caef52e | Panagiotis Kanavos | LocalHash = new Lazy<string>(() => Signature.CalculateMD5(LocalFile.FullName), LazyThreadSafetyMode.ExecutionAndPublication); |
50 | 1caef52e | Panagiotis Kanavos | } |
51 | 1caef52e | Panagiotis Kanavos | |
52 | 1caef52e | Panagiotis Kanavos | } |
53 | 1caef52e | Panagiotis Kanavos | } |