Selaa lähdekoodia

Content migration script: Add missing queryNodeApi to AssetsManager, add more debug logs and DEBUG env

Leszek Wiesner 3 vuotta sitten
vanhempi
commit
22b0d3ba23

+ 1 - 1
utils/migration-scripts/src/logging.ts

@@ -10,7 +10,7 @@ winston.addColors(colors)
 
 export function createLogger(label: string): Logger {
   return winston.createLogger({
-    level: 'debug',
+    level: process.env.DEBUG ? 'debug' : 'info',
     transports: [new winston.transports.Console()],
     defaultMeta: { label },
     format: winston.format.combine(

+ 2 - 0
utils/migration-scripts/src/sumer-giza/AssetsManager.ts

@@ -202,9 +202,11 @@ export class AssetsManager {
     let lastError: Error | undefined
     for (const endpoint of endpoints) {
       try {
+        this.logger.debug(`Trying to fetch asset ${contentId} from ${endpoint}...`)
         const tmpAssetPath = await this.fetchAsset(endpoint, contentId, expectedSize)
         return tmpAssetPath
       } catch (e) {
+        this.logger.debug(`Fetching ${contentId} from ${endpoint} failed: ${(e as Error).message}`)
         lastError = e as Error
         continue
       }

+ 1 - 0
utils/migration-scripts/src/sumer-giza/ContentMigration.ts

@@ -54,6 +54,7 @@ export class ContentMigration {
     const forcedChannelOwner = await this.getForcedChannelOwner()
     const assetsManager = await AssetsManager.create({
       api,
+      queryNodeApi,
       config,
     })
     const { idsMap: channelsMap, videoIds } = await new ChannelMigration({