mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-02 03:48:05 +08:00
fix scanner
This commit is contained in:
parent
55346f647e
commit
a4c04d0a6b
@ -210,11 +210,11 @@ public class StaticFileStorageController extends BaseServerController {
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
@GetMapping(value = "has-file", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@GetMapping(value = "scanner", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Feature(method = MethodFeature.LIST)
|
||||
public IJsonMessage<String> scanner(HttpServletRequest request) {
|
||||
boolean scanning = staticFileStorageService.isScanning();
|
||||
Assert.state(scanning, "当前正在扫描中");
|
||||
Assert.state(!scanning, "当前正在扫描中");
|
||||
String workspace = fileStorageService.getCheckUserWorkspace(request);
|
||||
staticFileStorageService.scanByWorkspace(workspace);
|
||||
return JsonMessage.success("扫描成功");
|
||||
|
@ -142,6 +142,13 @@ public class StaticFileStorageService extends BaseDbService<StaticFileStorageMod
|
||||
// 开启任务
|
||||
watchMonitor = new HashMap<>(list.size());
|
||||
for (String s : list) {
|
||||
File file = FileUtil.file(s);
|
||||
if (!FileUtil.exist(file)) {
|
||||
log.warn("被监控的目录不存在忽略创建监听器:{}", s);
|
||||
// 自动删除已经存在的任务
|
||||
this.delete(file);
|
||||
continue;
|
||||
}
|
||||
DelayWatcher delayWatcher = new DelayWatcher(StaticFileStorageService.this, 1000);
|
||||
WatchMonitor monitor = WatchUtil.createAll(s, watchMonitorMaxDepth, delayWatcher);
|
||||
watchMonitor.put(s, monitor);
|
||||
@ -149,7 +156,6 @@ public class StaticFileStorageService extends BaseDbService<StaticFileStorageMod
|
||||
ThreadUtil.execute(monitor);
|
||||
}
|
||||
}
|
||||
this.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -228,6 +234,8 @@ public class StaticFileStorageService extends BaseDbService<StaticFileStorageMod
|
||||
private void scanItem(String staticDir, String item, int level, Long taskId) {
|
||||
File file = FileUtil.file(item);
|
||||
if (!FileUtil.exist(file)) {
|
||||
// 目录不存在了,自动删除
|
||||
this.delete(file);
|
||||
return;
|
||||
}
|
||||
if (FileUtil.isFile(file)) {
|
||||
|
@ -41,3 +41,11 @@ export function hasStaticFile(params) {
|
||||
params: params,
|
||||
});
|
||||
}
|
||||
|
||||
export function staticScanner(params) {
|
||||
return axios({
|
||||
url: "/file-storage/static/scanner",
|
||||
method: "get",
|
||||
params: params,
|
||||
});
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
<a-button type="primary" :loading="loading" @click="loadData">搜索</a-button>
|
||||
</a-tooltip>
|
||||
<!-- <a-button type="primary" @click="handleUpload">上传文件</a-button> -->
|
||||
<a-button type="primary" @click="reScanner">扫描</a-button>
|
||||
|
||||
<a-button type="danger" :disabled="!tableSelections || tableSelections.length <= 0" @click="handleBatchDelete"> 批量删除 </a-button>
|
||||
</a-space>
|
||||
@ -74,7 +75,7 @@
|
||||
</a-space>
|
||||
</template>
|
||||
</a-table>
|
||||
<!-- 上传文件 -->
|
||||
<!-- 上传文件
|
||||
<a-modal destroyOnClose v-model="uploadVisible" :closable="!uploading" :footer="uploading ? null : undefined" :keyboard="false" :title="`上传文件`" @ok="handleUploadOk" :maskClosable="false">
|
||||
<a-form-model ref="form" :rules="rules" :model="temp" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
|
||||
<a-form-model-item label="选择文件" prop="file">
|
||||
@ -135,7 +136,7 @@
|
||||
<a-textarea v-model="temp.description" placeholder="请输入文件描述" />
|
||||
</a-form-model-item>
|
||||
</a-form-model>
|
||||
</a-modal>
|
||||
</a-modal> -->
|
||||
<!-- 编辑文件 -->
|
||||
<a-modal destroyOnClose v-model="editVisible" :title="`修改文件`" @ok="handleEditOk" :maskClosable="false">
|
||||
<a-form-model ref="editForm" :rules="rules" :model="temp" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
|
||||
@ -268,7 +269,7 @@
|
||||
<script>
|
||||
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, parseTime, renderSize, formatDuration, randomStr } from "@/utils/const";
|
||||
// import { uploadFile, uploadFileMerge, hasFile } from "@/api/file-manager/file-storage";
|
||||
import { staticFileStorageList, delFile, triggerUrl, fileEdit } from "@/api/file-manager/static-storage";
|
||||
import { staticFileStorageList, delFile, triggerUrl, fileEdit, staticScanner } from "@/api/file-manager/static-storage";
|
||||
// import { uploadPieces } from "@/utils/upload-pieces";
|
||||
import Vue from "vue";
|
||||
import releaseFile from "@/pages/file-manager/fileStorage/releaseFile";
|
||||
@ -616,6 +617,17 @@ export default {
|
||||
}
|
||||
this.$emit("confirm", selectData);
|
||||
},
|
||||
// 扫描
|
||||
reScanner() {
|
||||
staticScanner({}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.$notification.success({
|
||||
message: res.msg,
|
||||
});
|
||||
this.loadData();
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user