Exemplo n.º 1
0
 public FileContents(FileIdentity identity, string contents = null)
     : base(identity)
 {
     this.contents = contents;
     this.size     = contents.Length;
     this.hash     = Security.ComputeHash(contents);
 }
Exemplo n.º 2
0
 public FileContents(FileIdentity identity, string contents = null)
     : base(identity)
 {
     this.contents = contents;
     this.size = contents.Length;
     this.hash = Security.ComputeHash(contents);
 }
Exemplo n.º 3
0
        /// <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));
        }
Exemplo n.º 4
0
 public FileIdentity(FileIdentity fid)
     : this(fid.Name, fid.Modified, fid.Uploaded, fid.Type, fid.Size, fid.Hash)
 {
     //nothing needed here
 }
Exemplo n.º 5
0
 public bool DelFile(Credentials c, MachineIdentity mid, DirectoryIdentity did, FileIdentity f)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 public FileContents GetFileWithContent(Credentials c, MachineContents m, DirectoryContents d, FileIdentity f)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 8
0
 public bool DelFile(Credentials c, MachineIdentity m, DirectoryIdentity d,
         FileIdentity f)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 9
0
        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;
        }
Exemplo n.º 10
0
        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;
        }
Exemplo n.º 11
0
        public FileContents DownloadFile(IFileSyncModel connection, Credentials c,
				MachineIdentity m, DirectoryIdentity d, FileIdentity f)
        {
            throw new NotImplementedException();
        }
Exemplo n.º 12
0
 public FileContents ReadFileContents(FileIdentity fid, DirectoryIdentity did)
 {
     return this.ReadFileContents(did.LocalPath + "\\" + fid.Name);
 }
Exemplo n.º 13
0
        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);
            }
        }
Exemplo n.º 14
0
        public bool DelFile(Credentials c, MachineIdentity mid, DirectoryIdentity did,
				FileIdentity f)
        {
            var cl = new Ref.FileSyncModelClient();
            cl.Abort();
            throw new NotImplementedException();
        }
Exemplo n.º 15
0
 public FileContents(FileIdentity identity, string contents = null)
     : base(identity)
 {
     this.contents = contents;
 }
Exemplo n.º 16
0
 public FileIdentity(FileIdentity fid)
     : this(fid.Name, fid.Modified, fid.Uploaded, fid.Type, fid.Size, fid.Hash)
 {
     //nothing needed here
 }