From 18d8003f4ab5e02499da21fff23194fb8e8a1579 Mon Sep 17 00:00:00 2001 From: Pascal Le Merrer Date: Mon, 19 Jan 2026 14:13:52 +0100 Subject: [PATCH] Display destination directory content --- src/wrapper.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/wrapper.js b/src/wrapper.js index e2bd657..81934eb 100644 --- a/src/wrapper.js +++ b/src/wrapper.js @@ -60,3 +60,45 @@ app.ports.getSourceDirectoryContent.subscribe(function (directoryName) { app.ports.receiveError.send(msg); }); }); + +// Get destination directory files (directories are ignored) +app.ports.getDestinationDirectoryFiles.subscribe(function (directoryName) { + fs.readDir(directoryName, { recursive: false }) + .then((files) => { + Promise.all( + files.map((file) => { + return getFileMetadata(directoryName, file); + }), + ).then((metadata) => { + const filteredMetadata = metadata.filter((m) => { + return m != null && !m.IsDir; + }); + app.ports.receiveDestinationDirectoryFiles.send(filteredMetadata); + }); + }) + .catch((msg) => { + console.error(msg); + app.ports.receiveError.send(msg); + }); +}); + +// Get destination directory subdirectories +app.ports.getDestinationSubdirectories.subscribe(function (directoryName) { + fs.readDir(directoryName, { recursive: true }) + .then((files) => { + Promise.all( + files.map((file) => { + return getFileMetadata(directoryName, file); + }), + ).then((metadata) => { + const filteredMetadata = metadata.filter((m) => { + return m != null && m.IsDir; + }); + app.ports.receiveSubDirectories.send(filteredMetadata); + }); + }) + .catch((msg) => { + console.error(msg); + app.ports.receiveError.send(msg); + }); +});