public static void AddToQueue(string filepath)
 {
     if (FileHashStore.HasChangedOrIsNew(filepath))
     {
         Queue.Add(filepath);
     }
 }
예제 #2
0
        private static void ProcessQueue()
        {
            for (int i = _cache.Count - 1; i >= 0; i--)
            {
                var entry = _cache.ElementAt(i);

                // The file should be 1 second old before we start processing
                if (entry.Value > DateTime.Now.AddSeconds(-1))
                {
                    continue;
                }

                if (!_store.HasChangedOrIsNew(entry.Key))
                {
                    _cache.Remove(entry.Key);
                    continue;
                }

                try
                {
                    Minify(entry.Key);

                    _store.Save(entry.Key);
                    _cache.Remove(entry.Key);
                }
                catch (IOException)
                {
                    // Do nothing, let's try again next time
                }
                catch
                {
                    _cache.Remove(entry.Key);
                }
            }
        }
예제 #3
0
        private static void ProcessQueue()
        {
            if (_isProcessing)
            {
                return;
            }

            _isProcessing = true;
            int length = _cache.Count - 1;

            for (int i = length; i >= 0; i--)
            {
                if (_cache.Count < i)
                {
                    continue;
                }

                var entry = _cache.ElementAt(i);

                try
                {
                    // The file should be a second old before we start processing
                    if (entry.Value > DateTime.Now.AddSeconds(-2))
                    {
                        continue;
                    }

                    if (!_store.HasChangedOrIsNew(entry.Key))
                    {
                        _cache.Remove(entry.Key);
                        continue;
                    }

                    _compressor.CompressFile(entry.Key);
                    _cache.Remove(entry.Key);
                }
                catch (IOException)
                {
                    // do nothing. We'll try again
                }
                catch
                {
                    _cache.Remove(entry.Key);
                }
            }

            _isProcessing = false;
        }
예제 #4
0
파일: Program.cs 프로젝트: Injac/AzureJobs
 /// <summary>
 /// Determine whether to skip the compression of this file. This method determines whether the user has
 /// sent the force parameter, and whether the hash entry is new or has changed since last run. If either are false, then the
 /// file should be processed/compressed.
 /// </summary>
 /// <param name="entryKey">The key of the file store hash to check</param>
 private static bool ShouldSkipFileEntry(string entryKey)
 {
     return(_shouldForceOptimizeAllFiles == false && _store.HasChangedOrIsNew(entryKey) == false);
 }