Moved file management into upload repository
Minor visual tweaks
This commit is contained in:
parent
bb91384cab
commit
c466db2431
@ -258,25 +258,7 @@ module.exports = (repository) =>
|
||||
return;
|
||||
}
|
||||
|
||||
repository.uploads.delete(upload.id);
|
||||
|
||||
await Promise.all(upload.files.map(async (file) =>
|
||||
{
|
||||
if (!file.id) return;
|
||||
if (!(await repository.uploads.fileExists(file.id)))
|
||||
{
|
||||
var fullpath = resolvePath(config.fileUpload.path, file.id);
|
||||
try
|
||||
{
|
||||
await fs.unlink(fullpath);
|
||||
}
|
||||
catch (err)
|
||||
{
|
||||
console.log('Failed to delete ' + fullpath);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
await repository.uploads.delete(upload.id);
|
||||
res.sendStatus(200);
|
||||
});
|
||||
}));
|
||||
|
@ -1,5 +1,8 @@
|
||||
const map = require('lodash/map');
|
||||
const filter = require('lodash/filter');
|
||||
const resolvePath = require('resolve-path');
|
||||
const fs = require('mz/fs');
|
||||
const config = require('../../config');
|
||||
|
||||
|
||||
class Upload
|
||||
@ -137,7 +140,7 @@ class UploadRepository
|
||||
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
self.store.remove({ _id: uploadId }, (err, numRemoved) =>
|
||||
self.store.findOne({ _id: uploadId }, (err, doc) =>
|
||||
{
|
||||
if (err)
|
||||
{
|
||||
@ -145,7 +148,41 @@ class UploadRepository
|
||||
return;
|
||||
}
|
||||
|
||||
resolve();
|
||||
if (doc === null)
|
||||
{
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
let upload = new Upload(doc);
|
||||
|
||||
self.store.remove({ _id: uploadId }, async (err, numRemoved) =>
|
||||
{
|
||||
if (err)
|
||||
{
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
|
||||
await Promise.all(upload.files.map(async (file) =>
|
||||
{
|
||||
if (!file.id) return;
|
||||
if (!(await self.fileExists(file.id)))
|
||||
{
|
||||
var fullpath = resolvePath(config.fileUpload.path, file.id);
|
||||
try
|
||||
{
|
||||
await fs.unlink(fullpath);
|
||||
}
|
||||
catch (err)
|
||||
{
|
||||
console.log('Failed to delete ' + fullpath);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
7556
package-lock.json
generated
7556
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -72,7 +72,7 @@ export default {
|
||||
created: 'Date created',
|
||||
description: 'Description',
|
||||
descriptionHint: 'The description will be visible only in the admin panel',
|
||||
expiration: 'Expiration',
|
||||
expiration: 'Expires after',
|
||||
message: 'Message',
|
||||
messageHint: 'The message will be displayed to the user on the upload page after the code is entered. Markdown is supported.',
|
||||
|
||||
|
@ -72,7 +72,7 @@ export default {
|
||||
created: 'Datum aangemaakt',
|
||||
description: 'Omschrijving',
|
||||
descriptionHint: 'De omschrijving is alleen zichtbaar in beheer',
|
||||
expiration: 'Verloopt',
|
||||
expiration: 'Verloopt na',
|
||||
message: 'Bericht',
|
||||
messageHint: 'Het bericht wordt getoond aan de gebruiker op de upload pagina na het invoeren van de code. Markdown kan worden gebruikt.',
|
||||
|
||||
@ -100,7 +100,7 @@ export default {
|
||||
add: 'Gebruiker toevoegen',
|
||||
|
||||
list: {
|
||||
username: '(Gebruikers)naam',
|
||||
username: 'Gebruiker / naam',
|
||||
inactive: '(inactief)',
|
||||
email: 'Email',
|
||||
actions: 'Acties'
|
||||
|
@ -12,10 +12,12 @@
|
||||
<a :href="getCodeUrl(code.id)" target="_blank">{{ getCodeUrl(code.id) }}</a>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div class="pure-control-group" v-if="code.id">
|
||||
<label for="user">{{ $t('admin.codes.detail.owner') }}</label>
|
||||
<input id="user" type="text" readonly :value="code.username" class="pure-input-2-3">
|
||||
</div>
|
||||
-->
|
||||
|
||||
<div class="pure-control-group" v-if="code.id">
|
||||
<label for="created">{{ $t('admin.codes.detail.created') }}</label>
|
||||
|
Loading…
Reference in New Issue
Block a user