|
|
|
@ -41,7 +41,7 @@ const migrate = (authFileName = 'auth.json'): Promise<Users> => new Promise(asyn
|
|
|
|
|
const oldUsers = fs.readJsonSync(authPath).users as OldUsers;
|
|
|
|
|
|
|
|
|
|
// Create a new users object
|
|
|
|
|
const newUsers: Users = { users: [], meta: {} };
|
|
|
|
|
const newUsers: Users = { users: [], meta: {}, cliKey: nanoid(32) };
|
|
|
|
|
newUsers.migrated = true;
|
|
|
|
|
|
|
|
|
|
// Loop through each user
|
|
|
|
@ -69,8 +69,9 @@ const migrate = (authFileName = 'auth.json'): Promise<Users> => new Promise(asyn
|
|
|
|
|
.catch(reject)
|
|
|
|
|
|
|
|
|
|
// Migrate the datafile (token => uploader)
|
|
|
|
|
.then(() => data().get())
|
|
|
|
|
.then((fileData: [string, FileData][]) =>
|
|
|
|
|
.then(() => (!data())
|
|
|
|
|
? (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.
|
|
|
|
|
// 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);
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
.catch((err: any) => log.warn(err.message))
|
|
|
|
|
)
|
|
|
|
|
// We did it hoofuckingray
|
|
|
|
|
.then(() => log.success('Migrated all auth & file data to new auth system'))
|
|
|
|
|
.then(() => resolve(newUsers))
|
|
|
|
|