Display destination directory content
This commit is contained in:
parent
94003989ef
commit
18d8003f4a
1 changed files with 42 additions and 0 deletions
|
|
@ -60,3 +60,45 @@ app.ports.getSourceDirectoryContent.subscribe(function (directoryName) {
|
||||||
app.ports.receiveError.send(msg);
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue