mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
4660200b1e
Improvements related to albums: * Changed "rename album" option with a better "edit album" feature. With it you can also disable download or public link and even request a new public link (https://i.fiery.me/fz1y.png). This also adds a new API route: /api/albums/edit. The old API route, /api/albums/rename, is still available but will silently be using the new API in backend. * Deleting album will now also delete its zip archive if exists. * Renaming albums will also rename its zip archive if exists. * Generating zip will use async fs.readFile instead of fs.readFileSync. This should improve generating speed somewhat. * The codes that tries to generate random identifier for album will now check whether an album with the same identifier already exists. It will also rely on "uploads.maxTries" config option to limit how many times it will try to re-generate a new random identifier. * Added a new config option "uploads.albumIdentifierLength" which sets the length of the randomly generated identifier. * Added "download" and "public" columns to "albums" table in database/db.js. Existing users can run "node database/migration.js" to add the columns. Others: * uploadsController.getUniqueRandomName will no longer accept 3 paramters (previously it would accept a callback in the third parameter). It will now instead return a Promise. * Album name of disabled/deleted albums will no longer be shown in uploads list. * Added "fileLength" column to "users" table in database/db.js. * Renamed HTTP404.html and HTTP500.html in /pages/error to 404.html and 500.html respectively. I'm still using symlinks though. * Added a new CSS named sweetalert.css which will be used in homepage, auth and dashboard. It will style all sweetalert modals with dark theme (matching the current color scheme used in this branch). * Updated icons (added download icon). * Some other improvements/tweaks here and there.
36 lines
917 B
JavaScript
36 lines
917 B
JavaScript
const config = require('./../config')
|
|
const db = require('knex')(config.database)
|
|
|
|
const map = {
|
|
albums: {
|
|
editedAt: 'integer',
|
|
zipGeneratedAt: 'integer',
|
|
download: 'integer',
|
|
public: 'integer'
|
|
},
|
|
users: {
|
|
enabled: 'integer',
|
|
fileLength: 'integer'
|
|
}
|
|
}
|
|
|
|
const migration = {}
|
|
migration.start = async () => {
|
|
const tables = Object.keys(map)
|
|
await Promise.all(tables.map(table => {
|
|
const columns = Object.keys(map[table])
|
|
return Promise.all(columns.map(async column => {
|
|
if (await db.schema.hasColumn(table, column)) { return }
|
|
const columnType = map[table][column]
|
|
return db.schema.table(table, t => { t[columnType](column) })
|
|
.then(() => console.log(`Added column "${column}" to table "${table}".`))
|
|
.catch(console.error)
|
|
}))
|
|
}))
|
|
|
|
console.log('Migration finished! Now start lolisafe normally')
|
|
process.exit(0)
|
|
}
|
|
|
|
migration.start()
|