|
@@ -58,13 +58,14 @@ class DiskService extends CrudService {
|
|
|
async dirDelete(filePath, times) {
|
|
|
if (fs.existsSync(filePath)) {
|
|
|
const files = fs.readdirSync(filePath);
|
|
|
+ if (files.length > 0 && !times) throw new BusinessError(ErrorCode.SERVICE_FAULT, '内部有文件/目录,请先清空该目录');
|
|
|
+
|
|
|
for (const file of files) {
|
|
|
const curPath = path.resolve(filePath, file);
|
|
|
const fi = fs.statSync(curPath);
|
|
|
if (fi.isDirectory()) {
|
|
|
- throw new BusinessError(ErrorCode.SERVICE_FAULT, '内部有文件/目录,请先清空该目录');
|
|
|
// recurse
|
|
|
- // this.dirDelete(curPath);
|
|
|
+ this.dirDelete(curPath);
|
|
|
} else {
|
|
|
// delete file
|
|
|
if (_.get(times, 'start_time') && _.get(times, 'end_time')) {
|