Ejemplo n.º 1
0
        public IHttpActionResult Execute()
        {
            var fileJob = new FileJob(new SourceFolderScanner());

            fileJob.Execute(null);
            return(Ok());
        }
Ejemplo n.º 2
0
        public static void DoTest(long size, string password, string salt)
        {
            FileInfo source   = null;
            FileInfo pending  = null;
            FileInfo target   = null;
            FileInfo restored = null;

            try
            {
                source = CreateRandomFile(size);
                string sourceHash = KeepHasher.GetHash(source);

                pending  = new FileInfo(source.FullName + ".pending");
                target   = new FileInfo(source.FullName + ".target");
                restored = new FileInfo(source.FullName + ".restored");

                IFile testFile = new TestFile()
                {
                    Name      = source.Name,
                    Sha256    = sourceHash,
                    SizeBytes = size
                };

                FileJob job = new FileJob(testFile, source.FullName, pending.FullName, target.FullName, FileJob.ModeEnum.CompressEncrypt, password, salt);
                job.Execute();

                FileJob job2 = new FileJob(testFile, target.FullName, pending.FullName, restored.FullName, FileJob.ModeEnum.DecryptDecompress, password, salt);
                job2.Execute();

                string restoredHash = KeepHasher.GetHash(restored);

                if (sourceHash != restoredHash)
                {
                    throw new Exception();
                }
            }
            finally
            {
                if (source != null && source.Exists)
                {
                    source.Delete();
                }
                if (pending != null && pending.Exists)
                {
                    pending.Delete();
                }
                if (target != null && target.Exists)
                {
                    target.Delete();
                }
                if (restored != null && restored.Exists)
                {
                    restored.Delete();
                }
            }
        }