Skip to content

Commit c9f6c61

Browse files
committed
Remove archive file from project root after upload
1 parent 8696bec commit c9f6c61

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

schemas/templates.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ NEWSCHEMA('Templates', function(schema) {
4343
}
4444

4545
if (model.template === 'restore') {
46-
PATH.exists(CONF.directory_dump + model.id + '-backup.tar.gz', function(e) {
46+
PATH.exists(CONF.directory_dump + model.app.id + '-backup.tar.gz', function(e) {
4747
if (e)
4848
$.success();
4949
else
@@ -80,7 +80,7 @@ NEWSCHEMA('Templates', function(schema) {
8080

8181
schema.addWorkflow('backup', function($, model) {
8282
if (model.backup)
83-
Exec('bash {0} {1} {2}'.format(PATH.private('backup.sh'), Path.join(CONF.directory_www, model.app.linker), Path.join(CONF.directory_dump, model.id + '-backup.tar.gz')), $.done());
83+
Exec('bash {0} {1} {2}'.format(PATH.private('backup.sh'), Path.join(CONF.directory_www, model.app.linker), Path.join(CONF.directory_dump, model.app.id + '-backup.tar.gz')), $.done());
8484
else
8585
$.success();
8686
});
@@ -109,14 +109,15 @@ NEWSCHEMA('Templates', function(schema) {
109109

110110
// Restore from backup
111111
if (model.template === 'restore') {
112-
Exec('tar -xzvf {0} --directory {1} > /dev/null'.format(CONF.directory_dump + model.id + '-backup.tar.gz', directory), function() {
112+
Exec('tar -xzvf {0} --directory {1} > /dev/null'.format(CONF.directory_dump + model.app.id + '-backup.tar.gz', directory), function() {
113113
SuperAdmin.wsnotify('app_template', model.app);
114114
Spawn('chown', ['-R', SuperAdmin.run_as_user.user, directory]);
115115
$.success();
116116
});
117117
} else {
118118
// Extract file
119119
Exec('unzip -o {0}.zip'.format(model.app.id), { cwd: directory }, function() {
120+
PATH.unlink('{0}/{1}.zip'.format(directory, model.app.id));
120121
SuperAdmin.wsnotify('app_template', model.app);
121122
Spawn('chown', ['-R', SuperAdmin.run_as_user.user, directory]);
122123
$.success();

0 commit comments

Comments
 (0)