accountInfo.BlockHash));
break;
case FileStatus.Deleted:
- if (fileState != null)
- {
- var children = StatusKeeper.GetChildren(fileState);
- foreach (var child in children)
- {
- var childInfo = child.IsFolder
- ? (FileSystemInfo) new DirectoryInfo(child.FilePath)
- : new FileInfo(child.FilePath);
- NetworkAgent.Post(new CloudDeleteAction(accountInfo, childInfo, child));
- }
- }
+ DeleteChildObjects(state, fileState);
NetworkAgent.Post(new CloudDeleteAction(accountInfo, info, fileState));
break;
case FileStatus.Renamed:
: new FileInfo(state.Path);
NetworkAgent.Post(new CloudMoveAction(accountInfo, CloudActionType.RenameCloud,
oldInfo,
- newInfo));
+ newInfo));
+ //TODO: Do I have to move children as well or will Pithos handle this?
+ //Need to find all children of the OLD filepath
+ MoveChildObjects(state);
break;
}
}
}
}
+ private void DeleteChildObjects(WorkflowState state, FileState fileState)
+ {
+ if (fileState != null)
+ {
+ var children = StatusKeeper.GetChildren(fileState);
+ foreach (var child in children)
+ {
+ var childInfo = child.IsFolder
+ ? (FileSystemInfo) new DirectoryInfo(child.FilePath)
+ : new FileInfo(child.FilePath);
+ NetworkAgent.Post(new CloudDeleteAction(state.AccountInfo, childInfo, child));
+ }
+ }
+ }
+
+ private void MoveChildObjects(WorkflowState state)
+ {
+ var oldFileState = StatusKeeper.GetStateByFilePath(state.OldPath);
+ if (oldFileState != null)
+ {
+ var children = StatusKeeper.GetChildren(oldFileState);
+ foreach (var child in children)
+ {
+ var newPath = Path.Combine(state.Path, child.FilePath.Substring(state.OldPath.Length+1));
+
+ var oldMoveInfo = child.IsFolder
+ ? (FileSystemInfo) new DirectoryInfo(child.FilePath)
+ : new FileInfo(child.FilePath);
+ var newMoveInfo = child.IsFolder
+ ? (FileSystemInfo) new DirectoryInfo(newPath)
+ : new FileInfo(newPath);
+ //The new file path will be created by trimming the old root path
+ //and substituting the new root path
+
+ NetworkAgent.Post(new CloudMoveAction(state.AccountInfo, CloudActionType.RenameCloud,
+ oldMoveInfo, newMoveInfo));
+ }
+ }
+ }
+
//Starts interrupted files for a specific account
public void RestartInterruptedFiles(AccountInfo accountInfo)