예제 #1
0
 private void do_hashZ(string zipfile, string archivefilename, string outfilepath)
 {
     try
     {
         var phash = _hasher.CalculateDctHash(outfilepath);
         Form1.HashZipEntry hze = new Form1.HashZipEntry();
         hze.ZipFile   = zipfile;
         hze.InnerPath = archivefilename;
         hze.phash     = phash;
         _hashedZ.Add(hze);
     }
     catch (Exception ex)
     {
         _log.log(string.Format("{0}-{1}-{2}", zipfile, archivefilename, outfilepath));
         _log.log(ex);
     }
     Task.Factory.StartNew(() => OneThreadDone(), token, TaskCreationOptions.None, _guiContext); // TODO consider switching to ContinueWith
 }
예제 #2
0
        // TODO merge with MasterDetailBase
        private void LoadExistingHash()
        {
            var toload2 = Path.Combine(_path, "htih_pz.txt");

            if (!File.Exists(toload2))
            {
                return;
            }

            _lastHashTime = File.GetCreationTime(toload2);

            using (var sr = new StreamReader(toload2))
            {
                while (sr.Peek() >= 0)
                {
                    var line = sr.ReadLine();
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }

                    var parts = line.Split('|');
                    var he    = new Form1.HashZipEntry();
                    he.ZipFile   = parts[0];
                    he.InnerPath = parts[1];
                    he.phash     = ulong.Parse(parts[2]);

                    // Need a set of ZIPs to compare
                    if (_zipDict.ContainsKey(he.ZipFile))
                    {
                        var filelist = _zipDict[he.ZipFile];
                        filelist.Add(he);
                    }
                    else
                    {
                        var filelist = new ConcurrentBag <Form1.HashZipEntry>();
                        filelist.Add(he);
                        _zipDict[he.ZipFile] = filelist;
                    }
                }
            }
        }