Skip to content

Commit 7a5ad52

Browse files
committed
fix: only scan added files, not copied/moved
However, ensure the data gets refreshed regardless, by hooking into the next client side file list update after seeing a copy/move.
1 parent e81830b commit 7a5ad52

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

octoprint_file_check/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ def get_assets(self):
7575
##~~ EventHandlerPlugin API
7676

7777
def on_event(self, event, payload):
78-
if event == octoprint.events.Events.FILE_ADDED:
78+
if (
79+
event == octoprint.events.Events.FILE_ADDED
80+
and payload.get("operation", "add") == "add"
81+
):
7982
self._executor.submit(
8083
self._validate_file, payload["storage"], payload["path"], payload["type"]
8184
)

octoprint_file_check/static/js/file_check.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ $(function () {
1717

1818
self.issueNotification = undefined;
1919

20+
self.checkUpdateOnNextFileRefresh = false;
21+
2022
const ISSUES = {
2123
travel_speed: {
2224
title: gettext("Travel Speed Placeholder"),
@@ -233,6 +235,12 @@ $(function () {
233235
}
234236
};
235237

238+
self.onEventFileAdded = (payload) => {
239+
if (payload.operation && payload.operation !== "add") {
240+
self.checkUpdateOnNextFileRefresh = true;
241+
}
242+
};
243+
236244
self._handleNotification = function (data) {
237245
let severity = "warning";
238246

@@ -345,6 +353,13 @@ $(function () {
345353
self.requestData();
346354
}
347355
);
356+
357+
self.filesViewModel.allItems.subscribe(() => {
358+
if (self.checkUpdateOnNextFileRefresh) {
359+
self.checkUpdateOnNextFileRefresh = false;
360+
self.requestData();
361+
}
362+
});
348363
};
349364

350365
self.onUserLoggedIn = self.onUserLoggedOut = function () {

0 commit comments

Comments
 (0)