mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-13 16:33:01 -06:00
Display unmatched mask on dirWatch on new files and better TZ handling
This commit is contained in:
parent
eaa77c0309
commit
d11cb792ea
|
|
@ -57,11 +57,18 @@ class DirWatch {
|
||||||
dirWatch.deleteAfter = false;
|
dirWatch.deleteAfter = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof dirWatch.disabled === 'boolean' && !dirWatch.disabled) {
|
||||||
|
delete dirWatch.disabled;
|
||||||
|
}
|
||||||
|
|
||||||
if (dirWatch.frequency === null || typeof dirWatch.frequency !== 'number') {
|
if (dirWatch.frequency === null || typeof dirWatch.frequency !== 'number') {
|
||||||
delete dirWatch.frequency;
|
delete dirWatch.frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dirWatch.mask === null || typeof dirWatch.mask !== 'string' || !dirWatch.mask.length) {
|
if (dirWatch.mask === null || (
|
||||||
|
!(typeof dirWatch.mask === 'string' && dirWatch.mask.length) &&
|
||||||
|
!(Array.isArray(dirWatch.mask) && dirWatch.mask.every((mask) => typeof mask === 'string' && mask.length))
|
||||||
|
)) {
|
||||||
delete dirWatch.mask;
|
delete dirWatch.mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,7 +130,10 @@ class DirWatch {
|
||||||
|
|
||||||
const debounceFn = (filename) => setTimeout(() => {
|
const debounceFn = (filename) => setTimeout(() => {
|
||||||
if (this.exists(filename)) {
|
if (this.exists(filename)) {
|
||||||
if (this.statFile(filename).size > 44) {
|
const stat = this.statFile(filename);
|
||||||
|
|
||||||
|
if (stat.isFile()) {
|
||||||
|
if (stat.size > 44) {
|
||||||
delete debounces[filename];
|
delete debounces[filename];
|
||||||
|
|
||||||
this.importDefaultType(dirWatch, filename);
|
this.importDefaultType(dirWatch, filename);
|
||||||
|
|
@ -132,10 +142,11 @@ class DirWatch {
|
||||||
debounces[filename] = debounceFn(filename);
|
debounces[filename] = debounceFn(filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, dirWatch.delay);
|
}, dirWatch.delay);
|
||||||
|
|
||||||
watcher.on('raw', (_, filename) => {
|
watcher.on('raw', (_, filename) => {
|
||||||
filename = path.resolve(dir, filename);
|
console.log(filename);
|
||||||
|
|
||||||
if (debounces[filename]) {
|
if (debounces[filename]) {
|
||||||
clearTimeout(debounces[filename]);
|
clearTimeout(debounces[filename]);
|
||||||
|
|
@ -159,12 +170,16 @@ class DirWatch {
|
||||||
const call = {};
|
const call = {};
|
||||||
|
|
||||||
if (dirWatch.mask) {
|
if (dirWatch.mask) {
|
||||||
const parsedMask = this.parseMask(dirWatch.mask, filename);
|
const parsedMask = Array.isArray(dirWatch.mask)
|
||||||
|
? dirWatch.mask.reduce((meta, mask) => meta !== null ? meta : this.parseMask(mask, filename), null)
|
||||||
|
: this.parseMask(dirWatch.mask, filename);
|
||||||
|
|
||||||
if (parsedMask) {
|
if (parsedMask) {
|
||||||
Object.assign(call, parsedMask);
|
Object.assign(call, parsedMask);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
console.error(`DirWatch: No matching mask for file ${filename}`);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -294,11 +309,21 @@ class DirWatch {
|
||||||
return obj;
|
return obj;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
if (data.date && (data.time || data.ztime)) {
|
if (data.date && data.time) {
|
||||||
const date = data.date.replace(/[^\d]]+/g, '').replace(/(\d{4})(\d{2})(\d{2})/g, '$1-$2-$3');
|
const date = data.date.replace(/[^\d]]+/g, '').replace(/(\d{4})(\d{2})(\d{2})/g, '$1-$2-$3');
|
||||||
const time = data.time.replace(/[^\\d]]+/g, '').replace(/(\d)(?=(\d{2})+$)/g, '$1:');
|
const time = data.time.replace(/[^\\d]]+/g, '').replace(/(\d)(?=(\d{2})+$)/g, '$1:');
|
||||||
|
|
||||||
const dateTime = new Date(`${date}T${time}${data.ztime ? 'Z' : ''}`);
|
const dateTime = new Date(`${date}T${time}`);
|
||||||
|
|
||||||
|
if (!isNaN(dateTime.getTime())) {
|
||||||
|
call.dateTime = dateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (data.date && data.ztime) {
|
||||||
|
const date = data.date.replace(/[^\d]]+/g, '').replace(/(\d{4})(\d{2})(\d{2})/g, '$1-$2-$3');
|
||||||
|
const time = data.ztime.replace(/[^\\d]]+/g, '').replace(/(\d)(?=(\d{2})+$)/g, '$1:');
|
||||||
|
|
||||||
|
const dateTime = new Date(`${date}T${time}Z`);
|
||||||
|
|
||||||
if (!isNaN(dateTime.getTime())) {
|
if (!isNaN(dateTime.getTime())) {
|
||||||
call.dateTime = dateTime;
|
call.dateTime = dateTime;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue