Skip to content

Commit

Permalink
setUserFile() bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
mschlgl committed Jun 19, 2024
1 parent bdf0a80 commit 867f5d2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* iobroker extron (SIS) Adapter V0.2.15 20240611
* iobroker extron (SIS) Adapter V0.2.15 20240618
*
* Copyright (c) 2020-2024, Bannsaenger <[email protected]>
*
Expand Down Expand Up @@ -2121,7 +2121,10 @@ class Extron extends utils.Adapter {
try {
let i = 0;
userFileList.sort(); // sort list alphabetically to resemble DSP configurator display
this.setObjectAsync(this.objectsTemplate.userflash.file._id, this.objectsTemplate.userflash.file);
this.log.info(`setUserFile(): deleting file objects...`);
await this.delObjectAsync(this.objectsTemplate.userflash.file._id,{recursive:true}); // delete files recursively
this.log.info(`setUserFile(): create files folder object...`);
await this.setObjectAsync(this.objectsTemplate.userflash.file._id, this.objectsTemplate.userflash.file);
for (const userFile of userFileList) { // check each line
if (userFile.match(/(\d+\b Bytes Left)/g)) {
this.fileList.freeSpace = Number(userFile.match(/\d+/g));
Expand All @@ -2136,6 +2139,7 @@ class Extron extends utils.Adapter {
if (this.file.fileName.match(/.raw$/)) { // check if AudioFile
i++;
this.fileList.files[i] = this.file; // add to filelist array
this.log.info(`setUserFile(): creating file object for: ${this.file.fileName}`);
await this.setObjectAsync(`fs.files.${i}`, this.objectsTemplate.userflash.files.channel);
await this.setObjectAsync(`fs.files.${i}.filename`, this.objectsTemplate.userflash.files.filename);
this.setState(`fs.files.${i}.filename`, this.file.fileName, true);
Expand Down

0 comments on commit 867f5d2

Please sign in to comment.