feat: rebuild page tree worker

This commit is contained in:
NGPixel
2019-10-07 00:06:47 -04:00
parent 2883437a0f
commit 38c33c58bb
10 changed files with 198 additions and 119 deletions

View File

@@ -97,7 +97,7 @@ module.exports = {
}
// Check source asset permissions
const assetSourcePath = (asset.folderId) ? hierarchy.map(h => h.slug).join('/') + `/${filename}` : filename
const assetSourcePath = (asset.folderId) ? hierarchy.map(h => h.slug).join('/') + `/${asset.filename}` : asset.filename
if (!WIKI.auth.checkAccess(context.req.user, ['manage:assets'], { path: assetSourcePath })) {
throw new WIKI.Error.AssetRenameForbidden()
}
@@ -118,6 +118,16 @@ module.exports = {
// Delete old asset cache
await asset.deleteAssetCache()
// Rename in Storage
await WIKI.models.storage.assetEvent({
event: 'renamed',
asset: {
...asset,
sourcePath: assetSourcePath,
destinationPath: assetTargetPath
}
})
return {
responseResult: graphHelper.generateSuccess('Asset has been renamed successfully.')
}
@@ -145,6 +155,12 @@ module.exports = {
await WIKI.models.assets.query().deleteById(args.id)
await asset.deleteAssetCache()
// Delete from Storage
await WIKI.models.storage.assetEvent({
event: 'deleted',
asset
})
return {
responseResult: graphHelper.generateSuccess('Asset has been deleted successfully.')
}