feat: rebuild page tree worker
This commit is contained in:
@@ -125,6 +125,14 @@ module.exports = class Asset extends Model {
|
||||
|
||||
// Move temp upload to cache
|
||||
await fs.move(opts.path, path.join(process.cwd(), `data/cache/${fileHash}.dat`), { overwrite: true })
|
||||
|
||||
// Add to Storage
|
||||
if (!opts.skipStorage) {
|
||||
await WIKI.models.storage.assetEvent({
|
||||
event: 'uploaded',
|
||||
asset
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
static async getAsset(assetPath, res) {
|
||||
|
@@ -251,7 +251,7 @@ module.exports = class Page extends Model {
|
||||
})
|
||||
|
||||
// -> Save Tags
|
||||
if (opts.tags.length > 0) {
|
||||
if (opts.tags && opts.tags.length > 0) {
|
||||
await WIKI.models.tags.associateTags({ tags: opts.tags, page })
|
||||
}
|
||||
|
||||
|
@@ -180,6 +180,17 @@ module.exports = class Storage extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
static async assetEvent({ event, asset }) {
|
||||
try {
|
||||
for (let target of this.targets) {
|
||||
await target.fn[`asset${_.capitalize(event)}`](asset)
|
||||
}
|
||||
} catch (err) {
|
||||
WIKI.logger.warn(err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
static async executeAction(targetKey, handler) {
|
||||
try {
|
||||
const target = _.find(this.targets, ['key', targetKey])
|
||||
|
Reference in New Issue
Block a user