Skip to content

Commit 6a5fde6

Browse files
committed
There is no node_fs.statfsSync in old node.js
1 parent 126ff5a commit 6a5fde6

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

application/net/work_crawler/task.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,12 @@ function module_code(library_namespace) {
286286
var partition_stats = library_namespace
287287
.partition_stats(this.main_directory);
288288
// console.trace(partition_stats);
289-
var free_space = partition_stats.bsize * partition_stats.bavail;
289+
var free_space = partition_stats && partition_stats.bsize
290+
* partition_stats.bavail;
290291
if (free_space < 4 * 1024 * 1024) {
291292
library_namespace.error('start_downloading: ' + '剩餘儲存空間過小,僅剩 '
292293
+ library_namespace.to_KiB(free_space) + '。');
294+
// 4: 最起碼會新開啟這麼多個檔案。
293295
if (partition_stats.bavail < 4) {
294296
callback && callback();
295297
return;

application/platform/nodejs.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ function module_code(library_namespace) {
9090
// get filesystem statistics
9191
// https://nodejs.org/api/fs.html#class-fsstatfs
9292
function partition_stats(directory_path) {
93+
// There is no node_fs.statfsSync in old node.js
94+
if (!node_fs.statfsSync)
95+
return;
96+
9397
var partition_stats;
9498
partition_stats = node_fs.statfsSync(directory_path);
9599
// Total free space: partition_stats.bsize * partition_stats.bfree
@@ -346,8 +350,11 @@ function module_code(library_namespace) {
346350
// gettext_config:{"id":"recursively-removing-subdirectories-of-$1"}
347351
T : [ 'Recursively removing subdirectories of %1', path ]
348352
}, 2, 'remove_fso');
353+
} else {
354+
// https://github.com/nodejs/node/issues/56049
355+
// https://github.com/nodejs/node/issues/58759
356+
library_namespace.debug('Delete ' + path, 3, 'remove_fso');
349357
}
350-
// https://github.com/nodejs/node/issues/56049
351358
// console.trace(path, recursive);
352359
node_fs.rmSync(path, {
353360
recursive : !!recursive

application/storage/EPUB.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,8 +2614,9 @@ function module_code(library_namespace) {
26142614
}
26152615
}, this);
26162616

2617-
// 先刪除舊的電子書檔案以防干擾。
2618-
library_namespace.remove_file(target_file);
2617+
library_namespace.debug('先刪除舊的電子書檔案以防干擾。', 1, 'archive_to_ZIP');
2618+
if (library_namespace.file_exists(target_file))
2619+
library_namespace.remove_file(target_file);
26192620

26202621
library_namespace.debug({
26212622
// gettext_config:{"id":"creating-an-ebook-with-7zip-$1"}

0 commit comments

Comments
 (0)