Skip to content

Commit 07cf567

Browse files
committed
fix x-device move
1 parent cd54187 commit 07cf567

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

handlers/courses/controller/groupMaterials.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ exports.post = function*() {
124124
// error, so delete all tmp files
125125
for (var i = 0; i < files.length; i++) {
126126
var file = files[i];
127-
fs.unlinkSync(file.path);
127+
yield fs.unlink(file.path);
128128
}
129129
this.addFlashMessage('error', e.message);
130130
this.redirect(this.originalUrl);
@@ -142,7 +142,7 @@ exports.post = function*() {
142142
for (let i = 0; i < files.length; i++) {
143143
let file = files[i];
144144
let originalFilename = transliterate(file.originalFilename).replace(/[^\d\w_.-]/gim, '');
145-
fs.renameSync(file.path, path.join(archiveDir, originalFilename));
145+
yield* move(file.path, path.join(archiveDir, originalFilename));
146146
this.log.debug("Moved to archive", file.path, '->', path.join(archiveDir, originalFilename));
147147
}
148148

@@ -153,7 +153,7 @@ exports.post = function*() {
153153
fse.ensureDir(path.dirname(filePath), callback);
154154
};
155155

156-
fs.renameSync(processedMaterialsZip, filePath);
156+
yield* move(processedMaterialsZip, filePath);
157157

158158
this.log.debug("Moved zipped result to", filePath);
159159

@@ -281,3 +281,10 @@ function* processFiles(name, files) {
281281
return workingDir + '.zip';
282282

283283
}
284+
285+
function* move(src, dst) {
286+
yield function(callback) {
287+
fse.copy(src, dst, callback);
288+
};
289+
yield fs.unlink(src);
290+
}

modules/iprotect/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function* protect(name, filePath, targetDir) {
100100

101101
yield* del(name);
102102

103-
fs.unlinkSync(protectedPath); // strange bluebird/cls warning if I yield unlink
103+
yield fs.unlink(protectedPath); // strange bluebird/cls warning if I yield unlink
104104

105105
}
106106

0 commit comments

Comments
 (0)