mc:Ignorable="d" \r
d:DesignHeight="300" d:DesignWidth="300">\r
<Grid>\r
- \r
+ <DataGrid ItemsSource="{Binding Groups}" \r
+ AutoGenerateColumns="False" CanUserAddRows="True">\r
+ <DataGrid.Columns>\r
+ <DataGridTemplateColumn >\r
+ <DataGridTemplateColumn.CellTemplate>\r
+ <DataTemplate>\r
+ <Button Content=" - " Command="DataGrid.DeleteCommand"/>\r
+ </DataTemplate>\r
+ </DataGridTemplateColumn.CellTemplate>\r
+ </DataGridTemplateColumn>\r
+ <DataGridTextColumn Binding="{Binding UserName}" Header="Name" />\r
+ <DataGridCheckBoxColumn Binding="{Binding Read}" Header="Read"/>\r
+ <DataGridCheckBoxColumn Binding="{Binding Write}" Header="Write"/>\r
+ </DataGrid.Columns>\r
+ </DataGrid>\r
</Grid>\r
</UserControl>\r
using System.Collections.Generic;\r
using System.Linq;\r
using System.Text;\r
+ using Caliburn.Micro;\r
\r
/// <summary>\r
/// TODO: Update summary.\r
/// </summary>\r
- public class GroupsViewModel\r
+ public class GroupsViewModel:PropertyChangedBase\r
{\r
+\r
+ private List<string> _groups;\r
+\r
+ public List<string> Groups\r
+ {\r
+ get { return _groups; }\r
+ set\r
+ {\r
+ _groups = value;\r
+ NotifyOfPropertyChange(() => Groups);\r
+ }\r
+ }\r
}\r
}\r
private bool Ignore(string filePath)
{
- var pithosPath = Path.Combine(RootPath, "pithos");
- if (pithosPath.Equals(filePath, StringComparison.InvariantCultureIgnoreCase))
- return true;
+ //Ignore all first-level directories and files
+ if (FoundBelowRoot(filePath, RootPath,1))
+ return true;
+
+ //Ignore first-level items under the "others" folder.
+ var othersPath = Path.Combine(RootPath, FolderConstants.OthersFolder);
+ if (FoundBelowRoot(filePath, othersPath,1))
+ return true;
+
+ //Ignore second-level (container) folders under the "others" folder.
+ if (FoundBelowRoot(filePath, othersPath,2))
+ return true;
+
+
+ //Ignore anything happening in the cache path
if (filePath.StartsWith(CachePath))
return true;
if (_ignoreFiles.ContainsKey(filePath.ToLower()))
return false;
}
+/* private static bool FoundInRoot(string filePath, string rootPath)
+ {
+ //var rootDirectory = new DirectoryInfo(rootPath);
+
+ //If the paths are equal, return true
+ if (filePath.Equals(rootPath, StringComparison.InvariantCultureIgnoreCase))
+ return true;
+
+ //If the filepath is below the root path
+ if (filePath.StartsWith(rootPath,StringComparison.InvariantCulture))
+ {
+ //Get the relative path
+ var relativePath = filePath.Substring(rootPath.Length + 1);
+ //If the relativePath does NOT contains a path separator, we found a match
+ return (!relativePath.Contains(@"\"));
+ }
+
+ //If the filepath is not under the root path, return false
+ return false;
+ }*/
+
+
+ private static bool FoundBelowRoot(string filePath, string rootPath,int level)
+ {
+ //var rootDirectory = new DirectoryInfo(rootPath);
+
+ //If the paths are equal, return true
+ if (filePath.Equals(rootPath, StringComparison.InvariantCultureIgnoreCase))
+ return true;
+
+ //If the filepath is below the root path
+ if (filePath.StartsWith(rootPath,StringComparison.InvariantCulture))
+ {
+ //Get the relative path
+ var relativePath = filePath.Substring(rootPath.Length + 1);
+ //If the relativePath does NOT contains a path separator, we found a match
+ var levels=relativePath.ToCharArray().Count(c=>c=='\\')+1;
+ return levels==level;
+ }
+
+ //If the filepath is not under the root path, return false
+ return false;
+ }
+
//Post a Change message for all events except rename
void OnFileEvent(object sender, FileSystemEventArgs e)
{
&&
state.FilePath.StartsWith(accountInfo.AccountPath)).ToList();*/
+
var deleteCandidates = FileState.Queryable
.Where(state => state.Modified <= pollTime
&&
state.FilePath.StartsWith(accountInfo.AccountPath)
&& state.FileStatus != FileStatus.Conflict).ToList();
-/*
- var deleteCandidates = (from state in FileState.Queryable
- where
- state.Modified <= pollTime
- && state.FilePath.StartsWith(accountInfo.AccountPath)
- && state.FileStatus != FileStatus.Conflict
- select state).ToList();
-*/
+ //TODO: filesToDelete must take into account the Others container
var filesToDelete = (from deleteCandidate in deleteCandidates
let localFile = FileInfoExtensions.FromPath(deleteCandidate.FilePath)
let relativeFilePath = localFile.AsRelativeTo(accountInfo.AccountPath)
- where !cloudFiles.Any(r => Path.Combine(r.Container, r.Name) == relativeFilePath)
+ where !cloudFiles.Any(r =>
+ Path.Combine(r.Container, r.Name) == relativeFilePath || //Own file
+ Path.Combine(FolderConstants.OthersFolder,r.Account, r.Container, r.Name) == relativeFilePath //Shared file
+ )
select localFile).ToList();
//On the first run
{
foreach (var item in filesToDelete)
{
- item.Delete();
+ if (item.Exists)
+ {
+ if ((item.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
+ {
+ item.Attributes = item.Attributes & ~FileAttributes.ReadOnly;
+
+ }
+ item.Delete();
+ }
StatusKeeper.ClearFileStatus(item.FullName);
}
StatusNotification.NotifyForFiles(filesToDelete, String.Format("{0} files were deleted",filesToDelete.Count),TraceLevel.Info);
if (Account != null)
{
pathParts.Push(Account);
- pathParts.Push("others");
+ pathParts.Push(FolderConstants.OthersFolder);
}
}
var finalPath=Path.Combine(pathParts.ToArray());
<ItemGroup>
<Compile Include="AccountSettings.cs" />
<Compile Include="FileInfoExtensions.cs" />
+ <Compile Include="FolderConstants.cs" />
<Compile Include="IPithosSettings.cs" />
<Compile Include="IStatusChecker.cs" />
<Compile Include="PermissionConverter.cs" />
using(var reader=new StreamReader(stream))
{
Debug.Assert(stream.Position == 0);
- //We need to cleanup the content before returning it because it contains
+ //We used to have to cleanup the content before returning it because it contains
//error content after the list of hashes
- var hashes = new List<string>();
- string line=null;
- //All lines up to the first empty line are hashes
- while(!String.IsNullOrWhiteSpace(line=reader.ReadLine()))
- {
- hashes.Add(line);
- }
+ //
+ //As of 30/1/2012, the result is a proper Json array so we don't need to read the content
+ //line by line
+
+ var serializer = new JsonSerializer();
+ var hashes=(List<string>)serializer.Deserialize(reader, typeof (List<string>));
return hashes;
}
+++ /dev/null
-namespace Pithos.Network
-{
- public static class FolderConstants
- {
- public static readonly string OthersFolder="others-shared";
- public static readonly string PithosContainer = "pithos";
- public static readonly string TrashContainer = "trash";
-
- public static readonly string CacheFolder = ".pithos.cache";
- }
-}
<Compile Include="AccountInfo.cs" />
<Compile Include="CloudFilesClient.cs" />
<Compile Include="ContainerInfo.cs" />
- <Compile Include="FolderConstants.cs" />
<Compile Include="ICloudClient.cs" />
<Compile Include="RestClient.cs">
<SubType>Component</SubType>