|
@@ -45,9 +45,7 @@
|
|
|
<div class="handle-item" style="margin-bottom: 5px;">
|
|
|
<p>
|
|
|
<b>文件名检索结果:</b>
|
|
|
- <span style="color: #F56C6C; font-size: 12px;" >共有 {{fileList.length}} 个文件</span>
|
|
|
- <span style="color: #F56C6C; font-size: 12px;" >,耗时 {{times / 1000}} 秒</span>
|
|
|
- {{test}}
|
|
|
+ <span style="color: #F56C6C; font-size: 12px;" >共有 {{fileList.length}} 个文件,搜索耗时 {{times / 1000}} 秒</span>
|
|
|
</p>
|
|
|
</div>
|
|
|
<div class="table-scroll">
|
|
@@ -354,9 +352,15 @@ export default {
|
|
|
files.map(item => {
|
|
|
let filename = item.substr(item.lastIndexOf('/')+1);
|
|
|
let title = filename.substr(0, filename.lastIndexOf('.'));
|
|
|
+ let suffix = filename.substr(filename.lastIndexOf('.'));
|
|
|
+ if(filename.indexOf('.') < 0){
|
|
|
+ title = filename;
|
|
|
+ suffix = '';
|
|
|
+ }
|
|
|
let res = regExp.exec(filename);
|
|
|
this.fileList.push({
|
|
|
title: title,
|
|
|
+ suffix: suffix, // 带.
|
|
|
name: filename,
|
|
|
match: res,
|
|
|
path: item,
|
|
@@ -402,29 +406,29 @@ export default {
|
|
|
|
|
|
setTimeout(() => {
|
|
|
for(let i = 0; i < this.fileList.length; i++){
|
|
|
- console.log(i, new Date().getTime());
|
|
|
if(i < size){
|
|
|
let item = this.fileList[i];
|
|
|
let newFilePath = newPath + separator + item.name;
|
|
|
- if(fse.existsSync(newFilePath)){
|
|
|
-
|
|
|
- }
|
|
|
+ console.log(i, new Date().getTime());
|
|
|
+ // if(fse.existsSync(newFilePath)){
|
|
|
+ // newFilePath = newPath + separator + item.title + '重复' + new Date().getTime() + i + item.suffix;
|
|
|
+ // }
|
|
|
try {
|
|
|
if(this.handleData.type == '1'){ // 复制
|
|
|
+ //fse.copySync(item.path, newFilePath);
|
|
|
+ //item.status = '2';
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- fse.copySync(item.path, newFilePath);
|
|
|
- item.status = '2';
|
|
|
-
|
|
|
-
|
|
|
- // fse.copy(item.path, newFilePath).then(() => {
|
|
|
- // console.log('复制成功!')
|
|
|
- // item.status = '2';
|
|
|
- // }).catch(err => {
|
|
|
- // console.error('复制失败', err)
|
|
|
- // item.status = '6';
|
|
|
- // });
|
|
|
+ fse.copy(item.path, newFilePath, {overwrite: false, errorOnExist: true}).then(() => {
|
|
|
+ console.log('复制成功!')
|
|
|
+ item.status = '2';
|
|
|
+ }).catch(err => {
|
|
|
+ let str = err.toString();
|
|
|
+ console.error('复制失败', err.toString(), item.path)
|
|
|
+ if(str.indexOf('already exists') > -1 && str.indexOf(item.name) > -1){
|
|
|
+ console.log('重新复制')
|
|
|
+ }
|
|
|
+ item.status = '6';
|
|
|
+ })
|
|
|
|
|
|
}
|
|
|
|
|
@@ -434,8 +438,14 @@ export default {
|
|
|
}
|
|
|
|
|
|
if(this.handleData.type == '3'){ // 删除
|
|
|
- fse.removeSync(item.path);
|
|
|
- item.status = '4'
|
|
|
+ // fse.removeSync(item.path);
|
|
|
+ // item.status = '4'
|
|
|
+ //异步
|
|
|
+ fse.remove(item.path).then(() => {
|
|
|
+ item.status = '4';
|
|
|
+ }).catch(err => {
|
|
|
+ item.status = '6';
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
if(this.handleData.type == '4'){ // 覆盖
|