|
@@ -27,10 +27,39 @@ export default class extends BaseSeeder {
|
|
|
// 填写Bucket名称。
|
|
// 填写Bucket名称。
|
|
|
bucket: Env.get('OSS_BUCKET')
|
|
bucket: Env.get('OSS_BUCKET')
|
|
|
})
|
|
})
|
|
|
- const dirs = await client.listV2({
|
|
|
|
|
- prefix: 'files/',
|
|
|
|
|
- delimiter: '/'
|
|
|
|
|
- })
|
|
|
|
|
- console.log(dirs)
|
|
|
|
|
|
|
+ // const dirs = await client.listV2({
|
|
|
|
|
+ // prefix: 'files/asdf',
|
|
|
|
|
+ // delimiter: '/'
|
|
|
|
|
+ // })
|
|
|
|
|
+ // console.log(dirs)
|
|
|
|
|
+ const downloaded = '/Volumes/Data HD/shortplay/downloaded'
|
|
|
|
|
+ const dir = '/Volumes/Data HD/shortplay/files'
|
|
|
|
|
+ const subDirs = fs
|
|
|
|
|
+ .readdirSync(downloaded)
|
|
|
|
|
+ .filter((file) => {
|
|
|
|
|
+ const stat = fs.statSync(path.join(downloaded, file))
|
|
|
|
|
+ return !stat.isDirectory() && !/^\./.test(file)
|
|
|
|
|
+ })
|
|
|
|
|
+ .sort()
|
|
|
|
|
+ .map((file) => {
|
|
|
|
|
+ return file.replace('.json', '')
|
|
|
|
|
+ })
|
|
|
|
|
+ for (let i = 0; i < 10; i++) {
|
|
|
|
|
+ const subDir = subDirs[i]
|
|
|
|
|
+ const files = fs.readdirSync(path.join(dir, subDir)).filter((file) => {
|
|
|
|
|
+ const stat = fs.statSync(path.join(dir, subDir, file))
|
|
|
|
|
+ return !stat.isDirectory()
|
|
|
|
|
+ })
|
|
|
|
|
+ const cover = files.find((file) => /^cover_/.test(file))
|
|
|
|
|
+
|
|
|
|
|
+ if (cover) {
|
|
|
|
|
+ const key = path.join('files', subDir, cover)
|
|
|
|
|
+ try {
|
|
|
|
|
+ await client.head(key)
|
|
|
|
|
+ await client.putACL(key, 'public-read')
|
|
|
|
|
+ console.log('exists', key)
|
|
|
|
|
+ } catch (error) {}
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|