Пример #1
0
        async Task PopulateContainer(StoreTier tier, BranchState state, string[] paths, ILogger log)
        {
            if (state.In(CloneDb, Fresh))
            {
                return;
            }

            async Task <(AzureBlobFileStore container, CloudBlobContainer legacy, StringPath[] rooDirs)> GetStorePrep(SemVersion version)
            {
                var container = Stores.Store(tier: tier, version: version);
                var legacy    = container.LegacyContainer();
                var rooDirs   = await container.ListDirs("").ToArrayAsync();

                return(container, legacy, rooDirs);
            }

            var source = await GetStorePrep(VersionInfo.ProdVersion);

            var dest = await GetStorePrep(VersionInfo.Version);

            foreach (var path in source.rooDirs.Where(d => paths == null || paths.Contains(d.ToString())))
            {
                var sourceBlob = source.legacy.GetDirectoryReference(path);
                var destBlob   = dest.legacy.GetDirectoryReference(path);
                await YtBackup.CopyBlobs(nameof(BranchEnvCreator), sourceBlob, destBlob, log);
            }
        }
Пример #2
0
        async Task CreateContainer(BranchState state, ILogger log)
        {
            var branchContainer = StorageCfg.Container(VersionInfo.Version);
            var containerExists = await branchContainer.ExistsAsync();

            if (containerExists)
            {
                log.Information("container {Container} exists, leaving as is", branchContainer.Uri);
            }

            if (!containerExists)
            {
                await branchContainer.CreateAsync();

                await branchContainer.SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Container });
            }

            var db    = StorageCfg.DbPath;
            var paths = state switch {
                Clone => new[] { db, StorageCfg.ImportPath },
                CloneBasic => new[] { StorageCfg.ImportPath, $"{db}/channels", $"{db}/channel_reviews", $"{db}/videos", $"{db}/video_extra" },
                _ => null
            };

            if (paths == null)
            {
                return;
            }

            var prodContainer = StorageCfg.Container(VersionInfo.ProdVersion);

            foreach (var path in paths)
            {
                var sourceBlob = prodContainer.GetDirectoryReference(path);
                var destBlob   = branchContainer.GetDirectoryReference(path);
                await YtBackup.CopyBlobs(nameof(BranchEnvCreator), sourceBlob, destBlob, log);
            }
        }
    }
Пример #3
0
        async Task CreateContainer(BranchState state, ILogger log)
        {
            var branchContainer = StorageCfg.Container(VersionInfo.Version);

            var exists = await branchContainer.ExistsAsync();

            if (exists)
            {
                log.Information("container {Container} exists, leaving as is", branchContainer.Uri);
                return;
            }

            await branchContainer.CreateAsync();

            await branchContainer.SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Container });

            if (state == BranchState.CopyProd)
            {
                var prodContainer = StorageCfg.Container(VersionInfo.ProdVersion);
                var sourceBlob    = prodContainer.GetDirectoryReference(StorageCfg.DbPath);
                var destBlob      = branchContainer.GetDirectoryReference(StorageCfg.DbPath);
                await YtBackup.CopyBlobs(nameof(BranchEnvCreator), sourceBlob, destBlob, log);
            }
        }