|
|
@ -41,7 +41,7 @@ const migrate = (authFileName = 'auth.json'): Promise<Users> => new Promise(asyn
|
|
|
|
const oldUsers = fs.readJsonSync(authPath).users as OldUsers;
|
|
|
|
const oldUsers = fs.readJsonSync(authPath).users as OldUsers;
|
|
|
|
|
|
|
|
|
|
|
|
// Create a new users object
|
|
|
|
// Create a new users object
|
|
|
|
const newUsers: Users = { users: [], meta: {} };
|
|
|
|
const newUsers: Users = { users: [], meta: {}, cliKey: nanoid(32) };
|
|
|
|
newUsers.migrated = true;
|
|
|
|
newUsers.migrated = true;
|
|
|
|
|
|
|
|
|
|
|
|
// Loop through each user
|
|
|
|
// Loop through each user
|
|
|
@ -69,8 +69,9 @@ const migrate = (authFileName = 'auth.json'): Promise<Users> => new Promise(asyn
|
|
|
|
.catch(reject)
|
|
|
|
.catch(reject)
|
|
|
|
|
|
|
|
|
|
|
|
// Migrate the datafile (token => uploader)
|
|
|
|
// Migrate the datafile (token => uploader)
|
|
|
|
.then(() => data().get())
|
|
|
|
.then(() => (!data())
|
|
|
|
.then((fileData: [string, FileData][]) =>
|
|
|
|
? (log.warn('data.json not found. This may be a new install?'), Promise.resolve())
|
|
|
|
|
|
|
|
: data().get().then((fileData: [string, FileData][]) =>
|
|
|
|
|
|
|
|
|
|
|
|
// ! A note about this block.
|
|
|
|
// ! A note about this block.
|
|
|
|
// I know it's gross. But using Promise.all crashes low-spec servers, so I had to do it this way. Sorry.
|
|
|
|
// I know it's gross. But using Promise.all crashes low-spec servers, so I had to do it this way. Sorry.
|
|
|
@ -100,7 +101,8 @@ const migrate = (authFileName = 'auth.json'): Promise<Users> => new Promise(asyn
|
|
|
|
|
|
|
|
|
|
|
|
runQueue(0);
|
|
|
|
runQueue(0);
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
|
|
|
|
.catch((err: any) => log.warn(err.message))
|
|
|
|
|
|
|
|
)
|
|
|
|
// We did it hoofuckingray
|
|
|
|
// We did it hoofuckingray
|
|
|
|
.then(() => log.success('Migrated all auth & file data to new auth system'))
|
|
|
|
.then(() => log.success('Migrated all auth & file data to new auth system'))
|
|
|
|
.then(() => resolve(newUsers))
|
|
|
|
.then(() => resolve(newUsers))
|
|
|
|