Esempio n. 1
0
        public string AddToRepository(string sourceDir, bool beta, string description)
        {
            if (!Configured())
            {
                return("Error : Not configured");
            }

            var build = Tools.GetFileRevision(sourceDir + @"\Yatse2.exe");

            if (build == 0)
            {
                return("Error : Invalid source dir");
            }

            if (Directory.Exists(_platformDir + @"\" + build))
            {
                return("Error : Build allready in repository");
            }

            Directory.CreateDirectory(_platformDir + @"\" + build);
            Directory.CreateDirectory(_platformDir + @"\" + build + @"\Files");

            var fileinfos = new Collection <FileInfo>();
            var files     = Directory.GetFiles(sourceDir, "*.*", SearchOption.AllDirectories);

            foreach (var file in files)
            {
                if (file.Contains(".pdb") || file.Contains(".vshost.") || file.Contains(".application"))
                {
                    continue;
                }
                var fileinfo = new FileInfo
                {
                    FilePath = file.Replace(sourceDir, ""),
                    FileHash = FileHash.GetFileHashString(file)
                };
                if (!File.Exists(_platformDir + @"\" + build + @"\Files\" +
                                 fileinfo.FileHash + ".dat"))
                {
                    File.Copy(file, _platformDir + @"\" + build + @"\Files\" +
                              fileinfo.FileHash + ".dat");
                }
                fileinfos.Add(fileinfo);
            }

            var versionFile = new VersionFile {
                Description = description, FileInfos = fileinfos
            };

            versionFile.Save(_repoDir + @"\xmls\Version_" + _platform + "_" + build + ".xml");

            var liste = new VersionList();

            liste.Load(_repoDir + @"\xmls\Versions_" + _platform + ".xml");
            liste.Version.Add(new VersionInfo {
                Beta = beta, Build = build
            });
            liste.Save(_repoDir + @"\xmls\Versions_" + _platform + ".xml");

            return(null);
        }