Ejemplo n.º 1
0
        void BuildRepository(IProgressMonitor monitor, Repository rootrep, string rootPath, string relFilePath, ArrayList allAddins)
        {
            DateTime lastModified = DateTime.MinValue;

            string mainFile = Path.Combine (rootPath, relFilePath);
            string mainPath = Path.GetDirectoryName (mainFile);

            Repository mainrep = (Repository) AddinStore.ReadObject (mainFile, typeof(Repository));
            if (mainrep == null) {
                mainrep = new Repository ();
            }

            bool modified = false;

            monitor.Log.WriteLine ("Checking directory: " + mainPath);
            foreach (string file in Directory.GetFiles (mainPath, "*.mpack")) {
                string fname = Path.GetFileName (file);
                PackageRepositoryEntry entry = (PackageRepositoryEntry) mainrep.FindEntry (fname);
                if (entry == null) {
                    entry = new PackageRepositoryEntry ();
                    AddinPackage p = (AddinPackage) Package.FromFile (file);
                    entry.Addin = (AddinInfo) p.Addin;
                    entry.Url = fname;
                    mainrep.AddEntry (entry);
                    modified = true;
                    monitor.Log.WriteLine ("Added addin: " + fname);
                }
                allAddins.Add (entry);

                DateTime date = File.GetLastWriteTime (file);
                if (date > lastModified)
                    lastModified = date;
            }

            ArrayList toRemove = new ArrayList ();
            foreach (PackageRepositoryEntry entry in mainrep.Addins)
                if (!File.Exists (Path.Combine (mainPath, entry.Url)))
                    toRemove.Add (entry);

            foreach (PackageRepositoryEntry entry in toRemove)
                mainrep.RemoveEntry (entry);

            if (modified || toRemove.Count > 0) {
                AddinStore.WriteObject (mainFile, mainrep);
                monitor.Log.WriteLine ("Updated " + relFilePath);
            }

            ReferenceRepositoryEntry repEntry = (ReferenceRepositoryEntry) rootrep.FindEntry (relFilePath);
            if (repEntry != null) {
                if (repEntry.LastModified < lastModified)
                    repEntry.LastModified = lastModified;
            } else {
                repEntry = new ReferenceRepositoryEntry ();
                repEntry.LastModified = lastModified;
                repEntry.Url = relFilePath;
                rootrep.AddEntry (repEntry);
            }

            foreach (string dir in Directory.GetDirectories (mainPath)) {
                string based = dir.Substring (rootPath.Length + 1);
                BuildRepository (monitor, rootrep, rootPath, Path.Combine (based, "main.mrep"), allAddins);
            }
        }
Ejemplo n.º 2
0
        void BuildRepository(IProgressMonitor monitor, Repository rootrep, string rootPath, string relFilePath, ArrayList allAddins)
        {
            DateTime lastModified = DateTime.MinValue;

            string mainFile = Path.Combine (rootPath, relFilePath);
            string mainPath = Path.GetDirectoryName (mainFile);
            string supportFileDir = Path.Combine (mainPath, addinFilesDir);

            if (File.Exists (mainFile))
                lastModified = File.GetLastWriteTime (mainFile);

            Repository mainrep = (Repository) AddinStore.ReadObject (mainFile, typeof(Repository));
            if (mainrep == null) {
                mainrep = new Repository ();
            }

            ReferenceRepositoryEntry repEntry = (ReferenceRepositoryEntry) rootrep.FindEntry (relFilePath);
            DateTime rootLastModified = repEntry != null ? repEntry.LastModified : DateTime.MinValue;

            bool modified = false;

            monitor.Log.WriteLine ("Checking directory: " + mainPath);
            foreach (string file in Directory.GetFiles (mainPath, "*.mpack")) {

                DateTime date = File.GetLastWriteTime (file);
                string fname = Path.GetFileName (file);
                PackageRepositoryEntry entry = (PackageRepositoryEntry) mainrep.FindEntry (fname);

                if (entry != null && date > rootLastModified) {
                    mainrep.RemoveEntry (entry);
                    DeleteSupportFiles (supportFileDir, entry.Addin);
                    entry = null;
                }

                if (entry == null) {
                    entry = new PackageRepositoryEntry ();
                    AddinPackage p = (AddinPackage) Package.FromFile (file);
                    entry.Addin = (AddinInfo) p.Addin;
                    entry.Url = fname;
                    entry.Addin.Properties.SetPropertyValue ("DownloadSize", new FileInfo (file).Length.ToString ());
                    ExtractSupportFiles (supportFileDir, file, entry.Addin);
                    mainrep.AddEntry (entry);
                    modified = true;
                    monitor.Log.WriteLine ("Added addin: " + fname);
                }
                allAddins.Add (entry);
            }

            ArrayList toRemove = new ArrayList ();
            foreach (PackageRepositoryEntry entry in mainrep.Addins) {
                if (!File.Exists (Path.Combine (mainPath, entry.Url))) {
                    toRemove.Add (entry);
                    modified = true;
                }
            }

            foreach (PackageRepositoryEntry entry in toRemove) {
                DeleteSupportFiles (supportFileDir, entry.Addin);
                mainrep.RemoveEntry (entry);
            }

            if (modified) {
                AddinStore.WriteObject (mainFile, mainrep);
                monitor.Log.WriteLine ("Updated " + relFilePath);
                lastModified = File.GetLastWriteTime (mainFile);
            }

            if (repEntry != null) {
                if (repEntry.LastModified < lastModified)
                    repEntry.LastModified = lastModified;
            } else if (modified) {
                repEntry = new ReferenceRepositoryEntry ();
                repEntry.LastModified = lastModified;
                repEntry.Url = relFilePath;
                rootrep.AddEntry (repEntry);
            }

            foreach (string dir in Directory.GetDirectories (mainPath)) {
                if (Path.GetFileName (dir) == addinFilesDir)
                    continue;
                string based = dir.Substring (rootPath.Length + 1);
                BuildRepository (monitor, rootrep, rootPath, Path.Combine (based, "main.mrep"), allAddins);
            }
        }
Ejemplo n.º 3
0
        void BuildRepository(IProgressMonitor monitor, Repository rootrep, string rootPath, string relFilePath, ArrayList allAddins)
        {
            DateTime lastModified = DateTime.MinValue;

            string mainFile       = Path.Combine(rootPath, relFilePath);
            string mainPath       = Path.GetDirectoryName(mainFile);
            string supportFileDir = Path.Combine(mainPath, addinFilesDir);

            if (File.Exists(mainFile))
            {
                lastModified = File.GetLastWriteTime(mainFile);
            }

            Repository mainrep = (Repository)AddinStore.ReadObject(mainFile, typeof(Repository));

            if (mainrep == null)
            {
                mainrep = new Repository();
            }

            ReferenceRepositoryEntry repEntry = (ReferenceRepositoryEntry)rootrep.FindEntry(relFilePath);
            DateTime rootLastModified         = repEntry != null ? repEntry.LastModified : DateTime.MinValue;

            bool modified = false;

            monitor.Log.WriteLine("Checking directory: " + mainPath);
            foreach (string file in Directory.GetFiles(mainPath, "*.mpack"))
            {
                DateTime date  = File.GetLastWriteTime(file);
                string   fname = Path.GetFileName(file);
                PackageRepositoryEntry entry = (PackageRepositoryEntry)mainrep.FindEntry(fname);

                if (entry != null && date > rootLastModified)
                {
                    mainrep.RemoveEntry(entry);
                    DeleteSupportFiles(supportFileDir, entry.Addin);
                    entry = null;
                }

                if (entry == null)
                {
                    entry = new PackageRepositoryEntry();
                    AddinPackage p = (AddinPackage)Package.FromFile(file);
                    entry.Addin = (AddinInfo)p.Addin;
                    entry.Url   = fname;
                    entry.Addin.Properties.SetPropertyValue("DownloadSize", new FileInfo(file).Length.ToString());
                    ExtractSupportFiles(supportFileDir, file, entry.Addin);
                    mainrep.AddEntry(entry);
                    modified = true;
                    monitor.Log.WriteLine("Added addin: " + fname);
                }
                allAddins.Add(entry);
            }

            ArrayList toRemove = new ArrayList();

            foreach (PackageRepositoryEntry entry in mainrep.Addins)
            {
                if (!File.Exists(Path.Combine(mainPath, entry.Url)))
                {
                    toRemove.Add(entry);
                    modified = true;
                }
            }

            foreach (PackageRepositoryEntry entry in toRemove)
            {
                DeleteSupportFiles(supportFileDir, entry.Addin);
                mainrep.RemoveEntry(entry);
            }

            if (modified)
            {
                AddinStore.WriteObject(mainFile, mainrep);
                monitor.Log.WriteLine("Updated " + relFilePath);
                lastModified = File.GetLastWriteTime(mainFile);
            }

            if (repEntry != null)
            {
                if (repEntry.LastModified < lastModified)
                {
                    repEntry.LastModified = lastModified;
                }
            }
            else if (modified)
            {
                repEntry = new ReferenceRepositoryEntry();
                repEntry.LastModified = lastModified;
                repEntry.Url          = relFilePath;
                rootrep.AddEntry(repEntry);
            }

            foreach (string dir in Directory.GetDirectories(mainPath))
            {
                if (Path.GetFileName(dir) == addinFilesDir)
                {
                    continue;
                }
                string based = dir.Substring(rootPath.Length + 1);
                BuildRepository(monitor, rootrep, rootPath, Path.Combine(based, "main.mrep"), allAddins);
            }
        }
Ejemplo n.º 4
0
        void BuildRepository(IProgressMonitor monitor, Repository rootrep, string rootPath, string relFilePath, ArrayList allAddins)
        {
            DateTime lastModified = DateTime.MinValue;

            string mainFile = Path.Combine(rootPath, relFilePath);
            string mainPath = Path.GetDirectoryName(mainFile);

            Repository mainrep = (Repository)AddinStore.ReadObject(mainFile, typeof(Repository));

            if (mainrep == null)
            {
                mainrep = new Repository();
            }

            bool modified = false;

            monitor.Log.WriteLine("Checking directory: " + mainPath);
            foreach (string file in Directory.GetFiles(mainPath, "*.mpack"))
            {
                string fname = Path.GetFileName(file);
                PackageRepositoryEntry entry = (PackageRepositoryEntry)mainrep.FindEntry(fname);
                if (entry == null)
                {
                    entry = new PackageRepositoryEntry();
                    AddinPackage p = (AddinPackage)Package.FromFile(file);
                    entry.Addin = (AddinInfo)p.Addin;
                    entry.Url   = fname;
                    mainrep.AddEntry(entry);
                    modified = true;
                    monitor.Log.WriteLine("Added addin: " + fname);
                }
                allAddins.Add(entry);

                DateTime date = File.GetLastWriteTime(file);
                if (date > lastModified)
                {
                    lastModified = date;
                }
            }

            ArrayList toRemove = new ArrayList();

            foreach (PackageRepositoryEntry entry in mainrep.Addins)
            {
                if (!File.Exists(Path.Combine(mainPath, entry.Url)))
                {
                    toRemove.Add(entry);
                }
            }

            foreach (PackageRepositoryEntry entry in toRemove)
            {
                mainrep.RemoveEntry(entry);
            }

            if (modified || toRemove.Count > 0)
            {
                AddinStore.WriteObject(mainFile, mainrep);
                monitor.Log.WriteLine("Updated " + relFilePath);
            }

            ReferenceRepositoryEntry repEntry = (ReferenceRepositoryEntry)rootrep.FindEntry(relFilePath);

            if (repEntry != null)
            {
                if (repEntry.LastModified < lastModified)
                {
                    repEntry.LastModified = lastModified;
                }
            }
            else
            {
                repEntry = new ReferenceRepositoryEntry();
                repEntry.LastModified = lastModified;
                repEntry.Url          = relFilePath;
                rootrep.AddEntry(repEntry);
            }

            foreach (string dir in Directory.GetDirectories(mainPath))
            {
                string based = dir.Substring(rootPath.Length + 1);
                BuildRepository(monitor, rootrep, rootPath, Path.Combine(based, "main.mrep"), allAddins);
            }
        }