public void AddPackage(IPackage package, IEnumerable <string> files) { log.Debug($"Upload Google Drive Package '{package.Name}' Version:'{package.Version}' in '{PropertyReposityoryRoot}'"); if (GetFile(package) != null) { RemovePackage(package); } var properties = new List <Property>() { new Property() { Key = PropertyModPackName, Value = PropertyReposityoryRoot, Visibility = "PRIVATE" }, new Property() { Key = PropertyVersion, Value = package.Version, Visibility = "PRIVATE" }, new Property() { Key = PropertyAuthors, Value = package.Authors, Visibility = "PRIVATE" }, new Property() { Key = PropertyOwners, Value = package.Owners, Visibility = "PRIVATE" }, new Property() { Key = PropertyProjectUrl, Value = package.ProjectUrl, Visibility = "PRIVATE" } }; if (package.Tags != null) { foreach (var t in package.Tags) { properties.Add(new Property() { Key = t, Value = t, Visibility = "PRIVATE" }); } } using (var stream = PackageBuilder.CreatePackage(package, files)) { Helper.UploadFile(driveService, stream, package.FileName(), package.Description, googleModRoot.Id, properties.ToArray()); } }
private void TestPackage(IPackage package) { var destFile = package.FileName(); using (var stream = PackageBuilder.CreatePackage(package, GetFiles(package))) { using (var fileStream = File.Create(destFile)) { stream.Seek(0, SeekOrigin.Begin); stream.CopyTo(fileStream); } } Assert.IsTrue(File.Exists(destFile)); var package2 = PackageReader.GetManifestFromPackageStream(File.OpenRead(destFile)); Assert.IsTrue((Package)package == (Package)package2); }
private Google.Apis.Drive.v2.Data.File GetFile(IPackage package) { var files = Helper.GetFiles(driveService, "properties has { key='" + PropertyModPackName + "' and value='" + PropertyReposityoryRoot + "' and visibility='PRIVATE' } and properties has { key='" + PropertyVersion + "' and value='" + package.Version + "' and visibility='PRIVATE' } and title='" + package.FileName() + "'"); if (files.Count > 0) { return(files[0]); } return(null); }