catch migration error
This commit is contained in:
parent
0bac435c72
commit
57402cca8b
1 changed files with 13 additions and 10 deletions
|
@ -30,7 +30,6 @@ Project.find({}, (err, projects) => {
|
||||||
const userId = project.user.valueOf();
|
const userId = project.user.valueOf();
|
||||||
project.files.forEach((file, fileIndex) => {
|
project.files.forEach((file, fileIndex) => {
|
||||||
if (file.url && file.url.includes(process.env.S3_BUCKET) && !file.url.includes(userId)) {
|
if (file.url && file.url.includes(process.env.S3_BUCKET) && !file.url.includes(userId)) {
|
||||||
console.log(file.url);
|
|
||||||
const key = file.url.split('/').pop();
|
const key = file.url.split('/').pop();
|
||||||
console.log(key);
|
console.log(key);
|
||||||
const params = {
|
const params = {
|
||||||
|
@ -38,6 +37,7 @@ Project.find({}, (err, projects) => {
|
||||||
CopySource: `${process.env.S3_BUCKET}/${key}`,
|
CopySource: `${process.env.S3_BUCKET}/${key}`,
|
||||||
Key: `${userId}/${key}`
|
Key: `${userId}/${key}`
|
||||||
};
|
};
|
||||||
|
try {
|
||||||
client.moveObject(params)
|
client.moveObject(params)
|
||||||
.on('err', (err) => {
|
.on('err', (err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -48,6 +48,9 @@ Project.find({}, (err, projects) => {
|
||||||
console.log(`updated file ${key}`);
|
console.log(`updated file ${key}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue