public FileContents(FileIdentity identity, string contents = null) : base(identity) { this.contents = contents; this.size = contents.Length; this.hash = Security.ComputeHash(contents); }
/// <summary> /// Compares metadata of the identity of the file. Does not compare the actual contents, /// and does not check whether the given object contains the contents of the file (or only /// its identity). /// </summary> /// <param name="o">object to compare</param> /// <returns>true if: name, size, hash and modification date are all the same /// in both objects</returns> public override bool Equals(object o) { if (!o.GetType().Equals(typeof(FileIdentity)) && !o.GetType().Equals(typeof(FileContents))) { return(false); } FileIdentity fid = (FileIdentity)o; return(fid.Name.Equals(Name) && fid.Size == Size && fid.Hash.Equals(Hash) && fid.Modified.Equals(Modified)); }
public FileIdentity(FileIdentity fid) : this(fid.Name, fid.Modified, fid.Uploaded, fid.Type, fid.Size, fid.Hash) { //nothing needed here }
public bool DelFile(Credentials c, MachineIdentity mid, DirectoryIdentity did, FileIdentity f) { throw new NotImplementedException(); }
public FileContents GetFileWithContent(Credentials c, MachineContents m, DirectoryContents d, FileIdentity f) { var fc = new FileContents(f); GetFileContentId(c, m, d, fc); using (filesyncEntitiesNew context = new filesyncEntitiesNew()) { Content c1 = (from o in context.Contents where o.content_id == f.Content select o).Single(); fc.Data = c1.content_data; } return fc; }
public FileContents GetFileWithContent(Credentials c, MachineContents m, DirectoryContents d, FileIdentity f) { throw new NotImplementedException(); }
public bool DelFile(Credentials c, MachineIdentity m, DirectoryIdentity d, FileIdentity f) { throw new NotImplementedException(); }
public List<FileContents> GetFileList(Credentials c, MachineContents m, DirectoryContents d) { List<FileContents> filelist = new List<FileContents>(); m.Directories=GetDirList(c, m); d.Id = (from o in m.Directories where o.Name == d.Name select o.Id).Single(); using (filesyncEntitiesNew context = new filesyncEntitiesNew()) { foreach (var x in (from f in context.Files join t in context.Types on f.type_id equals t.type_id where f.dir_id == d.Id select new { f, t.type_name })) { FileIdentity file = new FileIdentity(x.f.file_name, x.f.file_modified, x.f.file_uploaded, FileType.PlainText, x.f.file_size, x.f.file_hash); file.Content = x.f.content_id; file.Id = x.f.file_id; filelist.Add(new FileContents(file)); } } //d.Files = filelist; return filelist; }
public FileIdentity ReadFileMetadata(string localPath) { if (localPath == null) throw new ActionException("No file path was provided.", ActionType.File); int lastSlash = localPath.LastIndexOf('\\') + 1; string dirPath = localPath.Substring(0, lastSlash); string fileName = localPath.Substring(lastSlash); if (dirPath.Length == 0 || fileName.Length == 0 || localPath.Equals(EmptyLocalPath)) throw new ActionException("Unable to get file metadata from an ivalid path: '" + localPath + "'.", ActionType.File, MemeType.Fuuuuu); FileIdentity f = new FileIdentity(fileName, System.IO.File.GetLastWriteTime(localPath)); return f; }
public FileContents DownloadFile(IFileSyncModel connection, Credentials c, MachineIdentity m, DirectoryIdentity d, FileIdentity f) { throw new NotImplementedException(); }
public FileContents ReadFileContents(FileIdentity fid, DirectoryIdentity did) { return this.ReadFileContents(did.LocalPath + "\\" + fid.Name); }
public FileContents GetFileWithContent(Credentials c, MachineContents m, DirectoryContents d, FileIdentity fid) { var cl = new Ref.FileSyncModelClient(); try { FileContents f = null; f = cl.GetFileWithContent(c, m, d, f); cl.Close(); if (f == null) throw new ActionException("Received a null object.", ActionType.User); return f; } catch (Exception ex) { cl.Abort(); throw new ActionException("Error while downloading file contents from database.", ActionType.File, MemeType.Fuuuuu, ex); } }
public bool DelFile(Credentials c, MachineIdentity mid, DirectoryIdentity did, FileIdentity f) { var cl = new Ref.FileSyncModelClient(); cl.Abort(); throw new NotImplementedException(); }
public FileContents(FileIdentity identity, string contents = null) : base(identity) { this.contents = contents; }