示例#1
0
        public static string    TryGetCachedHash(string file)
        {
            if (NGSyncFoldersWindow.cachedHashes == null)
            {
                NGSyncFoldersWindow.LoadHashesCache();
            }

            string[] values;

            if (NGSyncFoldersWindow.cachedHashes.TryGetValue(file, out values) == true)
            {
                string currentWriteTime = System.IO.File.GetLastWriteTime(file).Ticks.ToString();

                if (currentWriteTime != values[0])
                {
                    values[0] = currentWriteTime;
                    values[1] = NGSyncFoldersWindow.ProcessHash(file);
                }

                return(values[1]);
            }

            string hash = NGSyncFoldersWindow.ProcessHash(file);

            NGSyncFoldersWindow.cachedHashes.Add(file, new string[] { System.IO.File.GetLastWriteTime(file).Ticks.ToString(), hash });
            return(hash);
        }
示例#2
0
        private void    Scan()
        {
            try
            {
                if (this.profile.useCache == false)
                {
                    if (NGSyncFoldersWindow.cachedHashes == null)
                    {
                        NGSyncFoldersWindow.cachedHashes = new Dictionary <string, string[]>();
                    }
                    else
                    {
                        NGSyncFoldersWindow.cachedHashes.Clear();
                    }
                }
                else
                {
                    if (EditorUtility.DisplayCancelableProgressBar(NGSyncFoldersWindow.Title, "Loading cache...", 0F) == true)
                    {
                        return;
                    }

                    NGSyncFoldersWindow.cachedHashes = null;
                    NGSyncFoldersWindow.LoadHashesCache();
                }

                float countActiveSlaves = 2F;                   // Cache + master

                for (int i = 0; i < this.profile.slaves.Count; i++)
                {
                    if (this.profile.slaves[i].active == true)
                    {
                        ++countActiveSlaves;
                    }
                }

                NGSyncFoldersWindow.progress = 1F / countActiveSlaves;

                this.profile.master.Scan(/*this.mode == ButtonMode.ScanAndWatch, */ this.profile.relativePath, this.profile.filters);
                for (int i = 0; i < this.profile.slaves.Count; i++)
                {
                    if (this.profile.slaves[i].active == true)
                    {
                        NGSyncFoldersWindow.progress = (i + 2F) / countActiveSlaves;
                        NGSyncFoldersWindow.slave    = i + 1;

                        this.profile.slaves[i].ScanDiff(/*this.mode == ButtonMode.ScanAndWatch, */ this.profile.master, this.profile.relativePath, this.profile.filters);
                    }
                    //else
                    //	this.profile.slaves[i].Dispose();
                }

                if (this.profile.useCache == true)
                {
                    NGSyncFoldersWindow.SaveCachedHashes();
                    this.UpdateCacheFileSize();
                }
            }
            catch (AbortScanException)
            {
                this.profile.master.Clear();

                for (int i = 0; i < this.profile.slaves.Count; i++)
                {
                    this.profile.slaves[i].Clear();
                }
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
        }