Example #1
0
        public PackageCacheService(string root, string packageCachePath) : base(ThreadPriority.Lowest, TimeSpan.FromMilliseconds(1000), TimeSpan.FromMinutes(10), TimeSpan.FromSeconds(15))
        {
            this.root             = root;
            this.packageCachePath = packageCachePath;
            this.logWriter        = new LogWriter(Path.Combine(this.packageCachePath, "Log.txt"));

            sweepsPath                 = Path.Combine(packageCachePath, "sweeps");
            nodeModulesPath            = Path.Combine(root, "node_modules");
            pathsToProcess             = new List <string>();
            pathsToNotProcess          = new List <string>();
            pathsProcessed             = new Dictionary <string, List <PathCacheStatus> >();
            installsFromCacheToProcess = new Dictionary <string, PackageWorkingInstallFromCache>();
            statusStack                = new Stack <CacheStatusType>();
            cacheStatusType            = CacheStatusType.Initialized;
            lockObject                 = LockManager.CreateObject();
            memoryStatus               = MemoryStatus.Create();
            currentActionVerb          = "No current action";
            packageModules             = new NpmNodeModules(nodeModulesPath);

            this.NothingToPoll = true;

            if (!Directory.Exists(nodeModulesPath))
            {
                Directory.CreateDirectory(nodeModulesPath);
            }

            fileSystemWatcher = new FileSystemWatcher(nodeModulesPath);
            fileSystemWatcher.EnableRaisingEvents = true;

            fileSystemWatcher.Created += FileSystemWatcher_Created;
            fileSystemWatcher.Changed += FileSystemWatcher_Changed;
        }
        public PackageWorkingInstallFromCache(string mode, string install, string cachePath, string packagePath, NpmNodeModules packageModules, PackageWorkingInstallFromCache parent = null)
        {
            var packageDirectory = new DirectoryInfo(packagePath);
            var cacheDirectory   = new DirectoryInfo(cachePath);

            this.Mode                = mode;
            this.Install             = install;
            this.CachePath           = cachePath;
            this.PackagePath         = packagePath;
            this.InstallStatusList   = new List <PackageInstallFromCacheStatus>();
            this.InstallActionsQueue = new Queue <InstallAction>();
            this.PackageModules      = packageModules;

            this.Parent = parent;

            nodeModulesPath = packageDirectory.GetParentPathToFolder("node_modules", true);
            cachePathRoot   = cacheDirectory.GetParentPathToFolder("cache", true);

            this.DependenciesFromCacheToProcess = new Dictionary <string, PackageWorkingInstallFromCache>();
            this.AllDependenciesToProcess       = new Dictionary <string, PackageWorkingInstallFromCache>();
        }