From 0ba85b0c512ec7d90b14ad92c412591c1cb555fd Mon Sep 17 00:00:00 2001 From: pkanavos Date: Wed, 23 May 2012 23:25:32 +0300 Subject: [PATCH] Modified the uploader to add new directories to Selected Folders if Selective Sync is enabled --- trunk/Pithos.Client.WPF/Properties/AssemblyInfo.cs | 6 ++-- trunk/Pithos.Core/Agents/SelectiveUris.cs | 17 +++++++++++ trunk/Pithos.Core/Agents/Uploader.cs | 9 +++++- trunk/Pithos.Core/Agents/WorkflowAgent.cs | 4 +-- trunk/Pithos.sln | 32 -------------------- 5 files changed, 30 insertions(+), 38 deletions(-) diff --git a/trunk/Pithos.Client.WPF/Properties/AssemblyInfo.cs b/trunk/Pithos.Client.WPF/Properties/AssemblyInfo.cs index bc46b2b..07e3c07 100644 --- a/trunk/Pithos.Client.WPF/Properties/AssemblyInfo.cs +++ b/trunk/Pithos.Client.WPF/Properties/AssemblyInfo.cs @@ -56,7 +56,7 @@ using System.Windows; [assembly: AssemblyCopyright("Copyright © GRNet 2011-2012")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyInformationalVersion("2012-05-15")] +[assembly: AssemblyInformationalVersion("2012-05-22")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from @@ -93,5 +93,5 @@ using System.Windows; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.7.20518.0")] -[assembly: AssemblyFileVersionAttribute("0.7.20518.0")] +[assembly: AssemblyVersion("0.7.20522.0")] +[assembly: AssemblyFileVersionAttribute("0.7.20522.0")] diff --git a/trunk/Pithos.Core/Agents/SelectiveUris.cs b/trunk/Pithos.Core/Agents/SelectiveUris.cs index db60ced..79a3f18 100644 --- a/trunk/Pithos.Core/Agents/SelectiveUris.cs +++ b/trunk/Pithos.Core/Agents/SelectiveUris.cs @@ -2,6 +2,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.ComponentModel.Composition; +using System.Diagnostics.Contracts; using System.IO; using System.Linq; using System.Text; @@ -18,6 +19,9 @@ namespace Pithos.Core.Agents private ConcurrentDictionary> SelectivePaths { get; set; } + [Import] + public IPithosSettings Settings { get; set; } + public Selectives() { SelectiveUris = new ConcurrentDictionary>(); @@ -123,5 +127,18 @@ namespace Pithos.Core.Agents return own.Union(others).ToList(); } + public void Save(AccountInfo account) + { + Contract.Requires(account!=null); + Contract.EndContractBlock(); + + var selections = SelectiveUris[account.AccountKey]; + var accountSettings= Settings.Accounts.First(acc => acc.AccountKey == account.AccountKey); + accountSettings.SelectiveFolders.Clear(); + accountSettings.SelectiveFolders.AddRange(selections.Select(uri => uri.ToString()).ToArray()); + Settings.Save(); + + } + } } diff --git a/trunk/Pithos.Core/Agents/Uploader.cs b/trunk/Pithos.Core/Agents/Uploader.cs index 59ddf66..5e2f158 100644 --- a/trunk/Pithos.Core/Agents/Uploader.cs +++ b/trunk/Pithos.Core/Agents/Uploader.cs @@ -24,7 +24,6 @@ namespace Pithos.Core.Agents [Import] private IStatusKeeper StatusKeeper { get; set; } - public IStatusNotification StatusNotification { get; set; } @@ -137,6 +136,14 @@ namespace Pithos.Core.Agents //Go on and create the directory await client.PutObject(account, cloudFile.Container, cloudFile.Name, fullFileName, String.Empty, "application/directory"); + //If the upload is in response to a Folder create with Selective Sync enabled + if (action.IsCreation) + { + //Add the folder to the Selected URls + var selections = Selectives.SelectiveUris[accountInfo.AccountKey]; + selections.Add(cloudFile.Uri); + Selectives.Save(accountInfo); + } } else { diff --git a/trunk/Pithos.Core/Agents/WorkflowAgent.cs b/trunk/Pithos.Core/Agents/WorkflowAgent.cs index acc5560..f56afef 100644 --- a/trunk/Pithos.Core/Agents/WorkflowAgent.cs +++ b/trunk/Pithos.Core/Agents/WorkflowAgent.cs @@ -108,9 +108,9 @@ namespace Pithos.Core.Agents if (Log.IsDebugEnabled) Log.DebugFormat("Skipping {0}", state.FileName); return CompletedTask.Default; - } + } - var info = Directory.Exists(state.Path) ? (FileSystemInfo)new DirectoryInfo(state.Path) : new FileInfo(state.Path); + var info = FileInfoExtensions.FromPath(state.Path);// Directory.Exists(state.Path) ? (FileSystemInfo)new DirectoryInfo(state.Path) : new FileInfo(state.Path); //Bypass deleted files, unless the status is Deleted if (!info.Exists && state.Status != FileStatus.Deleted) diff --git a/trunk/Pithos.sln b/trunk/Pithos.sln index 982c71a..0aea32e 100644 --- a/trunk/Pithos.sln +++ b/trunk/Pithos.sln @@ -45,8 +45,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pithos.Client.WPF.Test", "P EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pithos.Interfaces.Test", "Pithos.Interfaces.Test\Pithos.Interfaces.Test.csproj", "{881F7260-CA40-40FD-AEEC-860B346DC2DC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "log4netViewer", "log4netViewer\log4netViewer\log4netViewer.csproj", "{FF08C711-3DBC-4767-9600-CF68A64CFD55}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug All|Any CPU = Debug All|Any CPU @@ -598,36 +596,6 @@ Global {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|Mixed Platforms.Build.0 = Release|Any CPU {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|x64.ActiveCfg = Release|Any CPU {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|x86.ActiveCfg = Release|Any CPU - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Debug All|Any CPU.ActiveCfg = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Debug All|Mixed Platforms.ActiveCfg = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Debug All|Mixed Platforms.Build.0 = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Debug All|x64.ActiveCfg = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Debug All|x86.ActiveCfg = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Debug All|x86.Build.0 = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Debug|Any CPU.ActiveCfg = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Debug|x64.ActiveCfg = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Debug|x86.ActiveCfg = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Debug|x86.Build.0 = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Premium Debug|Any CPU.ActiveCfg = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Premium Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Premium Debug|Mixed Platforms.Build.0 = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Premium Debug|x64.ActiveCfg = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Premium Debug|x86.ActiveCfg = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Premium Debug|x86.Build.0 = Debug|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Release|Any CPU.ActiveCfg = Release|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Release|Mixed Platforms.Build.0 = Release|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Release|x64.ActiveCfg = Release|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Release|x86.ActiveCfg = Release|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Release|x86.Build.0 = Release|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Test|Any CPU.ActiveCfg = Release|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Test|Mixed Platforms.ActiveCfg = Release|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Test|Mixed Platforms.Build.0 = Release|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Test|x64.ActiveCfg = Release|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Test|x86.ActiveCfg = Release|x86 - {FF08C711-3DBC-4767-9600-CF68A64CFD55}.Test|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE -- 1.7.10.4