Пример #1
0
        public static void CleanAll(IEnumerable <string> files)
        {
            try
            {
                foreach (var file in files)
                {
                    try
                    {
                        var parentDirectory = Path.GetDirectoryName(file);
                        Disk.DeleteDirectory(Path.Combine(parentDirectory, ".stuff"));

                        foreach (var item in StuffObject.Load(file, StuffFlags.AcceptAll))
                        {
                            Disk.DeleteDirectory(
                                Path.Combine(
                                    parentDirectory,
                                    item.Key.Replace('/', Path.DirectorySeparatorChar)));
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Error(file.Relative() + ": " + e.Message);
                    }
                }
            }
            finally
            {
                DownloadCache.AutoCollect();
            }
        }
Пример #2
0
        public static bool InstallAll(IEnumerable <string> files, StuffFlags flags = 0, IEnumerable <string> optionalDefines = null)
        {
            try
            {
                var tasks  = new List <Task>();
                var retval = true;

                foreach (var file in files)
                {
                    tasks.Add(Task.Factory.StartNew(
                                  () =>
                    {
                        try
                        {
                            if (!Install(file, flags, optionalDefines))
                            {
                                retval = false;
                            }
                        }
                        catch (Exception e)
                        {
                            Log.Error(file.Relative() + ": " + e.Message);
                            retval = false;
                        }
                    }));
                }

                Task.WaitAll(tasks.ToArray());
                return(retval);
            }
            finally
            {
                DownloadCache.AutoCollect();
            }
        }
Пример #3
0
 public static bool Install(string filename, StuffFlags flags = 0, IEnumerable <string> optionalDefines = null)
 {
     try
     {
         return(new Installer(filename, flags, optionalDefines).Install());
     }
     finally
     {
         DownloadCache.AutoCollect();
     }
 }
Пример #4
0
        public static bool IsUpToDate(string filename, StuffFlags flags = 0, IEnumerable <string> optionalDefines = null)
        {
            try
            {
                var parentDir = Path.GetDirectoryName(filename);

                foreach (var item in StuffObject.Load(filename, flags, optionalDefines))
                {
                    var itemKey   = item.Key.Replace('/', Path.DirectorySeparatorChar);
                    var itemFile  = Path.Combine(parentDir, ".stuff", itemKey);
                    var targetDir = Path.Combine(parentDir, itemKey);
                    if (!IsItemUpToDate(targetDir, itemFile, item.Value?.ToString(), flags))
                    {
                        return(false);
                    }
                }

                return(true);
            }
            finally
            {
                DownloadCache.AutoCollect();
            }
        }