Skip to content

Commit 7fd8a8e

Browse files
author
Samy Laumonier
committed
fix bug suppression
1 parent b20f762 commit 7fd8a8e

File tree

4 files changed

+40
-16
lines changed

4 files changed

+40
-16
lines changed

meteor/lib/collections/collections.js

+6
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@ Collection.Files.helpers({
1818
},
1919
numeralSize: function () {
2020
return numeral(this.size).format('0.00 b');
21+
},
22+
cleanOutputFormat: function () {
23+
return this.outputFormat || '-';
24+
},
25+
cleanOutputSize: function () {
26+
return this.outputSize ? numeral(this.outputSize).format('0.00 b') : '-';
2127
}
2228
});

meteor/lib/tabulars/file.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ new Tabular.Table({
44
createdBy: userId
55
}),
66
collection: Collection.Files,
7+
responsive: true,
8+
autoWidth: false,
79
columns: [
8-
{ data: 'originalName', title: 'Name' },
9-
{ data: 'ext', title: 'Format' },
10-
{ data: 'numeralSize()', title: 'Size' },
10+
{ data: 'originalName', title: 'Original name' },
11+
{ data: 'ext', title: 'Original format' },
12+
{ data: 'numeralSize()', title: 'Original size' },
13+
{ data: 'cleanOutputFormat()', title: 'Output format' },
14+
{ data: 'cleanOutputSize()', title: 'Output size' },
1115
{ data: 'state()', title: 'Status' },
1216
{
1317
tmpl: Meteor.isClient && Template.profileFileActions,
@@ -17,5 +21,5 @@ new Tabular.Table({
1721
title: 'Actions'
1822
}
1923
],
20-
extraFields: ['id', 'size', 'status', 'isAudio', 'isVideo', 'price', 'outputFormat']
24+
extraFields: ['id', 'size', 'status', 'isAudio', 'isVideo', 'price', 'outputFormat', 'outputSize']
2125
});

meteor/server/file/method.js

+26-11
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ Meteor.methods({
123123

124124
Collection.Files.update(fileId, {
125125
$set: {
126-
status: 'converted'
126+
status: 'converted',
127+
outputSize: fileInfo.size
127128
}
128129
});
129130

@@ -141,20 +142,34 @@ Meteor.methods({
141142
},
142143
deleteFile: (fileId) => {
143144
const file = getFile(fileId);
144-
const filePath = Meteor.settings.data + file.path;
145145

146-
if (fs.existsSync(filePath)) {
147-
fs.unlinkSync(filePath);
148-
}
146+
if (file.status === 'new') {
147+
const filePath = Meteor.settings.data + file.path;
148+
149+
if (fs.existsSync(filePath)) {
150+
fs.unlinkSync(filePath);
151+
}
149152

150-
const size = file.size;
153+
Collection.Files.remove(fileId);
154+
Meteor.users.update(Meteor.userId(), {
155+
$inc: {
156+
'profile.diskUsage': -file.size
157+
}
158+
});
159+
} else if (file.status === 'converted') {
160+
const filePath = `${Meteor.settings.data}/${file.id}.${file.outputFormat}`;
151161

152-
Collection.Files.remove(fileId);
153-
Meteor.users.update(Meteor.userId(), {
154-
$inc: {
155-
'profile.diskUsage': -size
162+
if (fs.existsSync(filePath)) {
163+
fs.unlinkSync(filePath);
156164
}
157-
});
165+
166+
Collection.Files.remove(fileId);
167+
Meteor.users.update(Meteor.userId(), {
168+
$inc: {
169+
'profile.diskUsage': -file.outputSize
170+
}
171+
});
172+
}
158173
}
159174
});
160175

scripts/worker/worker.py

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def extract_part(is_video, input_path, start_at, stop_at):
3030
template = "ffmpeg -y -i {} -ss {} -t {} {}"
3131
t = '%.2f' % round(stop_at - start_at, 2)
3232
command = template.format(input_path, start_at, t, input_part_path)
33-
print(command)
3433
check_call(shlex.split(command), universal_newlines=True)
3534

3635
return input_part_path

0 commit comments

Comments
 (0)