new video json files created now get read perms across the board

This commit is contained in:
Isaac Grynsztein
2020-04-15 03:19:28 -04:00
parent e4851253dd
commit 2408184cc7

View File

@@ -709,22 +709,26 @@ function getFileSizeMp4(name)
return filesize; return filesize;
} }
function getJSONMp3(name) function getJSONMp3(name, openReadPerms = false)
{ {
var jsonPath = audioFolderPath+name+".info.json"; var jsonPath = audioFolderPath+name+".info.json";
var alternateJsonPath = audioFolderPath+name+".mp3.info.json"; var alternateJsonPath = audioFolderPath+name+".mp3.info.json";
var obj = null; var obj = null;
if (fs.existsSync(jsonPath)) if (fs.existsSync(jsonPath)) {
obj = JSON.parse(fs.readFileSync(jsonPath, 'utf8')); obj = JSON.parse(fs.readFileSync(jsonPath, 'utf8'));
else if (fs.existsSync(alternateJsonPath)) if (openReadPerms) fs.chmodSync(jsonPath, 0o755);
}
else if (fs.existsSync(alternateJsonPath)) {
obj = JSON.parse(fs.readFileSync(alternateJsonPath, 'utf8')); obj = JSON.parse(fs.readFileSync(alternateJsonPath, 'utf8'));
if (openReadPerms) fs.chmodSync(alternateJsonPath, 0o755);
}
else else
obj = 0; obj = 0;
return obj; return obj;
} }
function getJSONMp4(name, customPath = null) function getJSONMp4(name, customPath = null, openReadPerms = false)
{ {
var obj = null; // output var obj = null; // output
let jsonPath = null; let jsonPath = null;
@@ -738,9 +742,10 @@ function getJSONMp4(name, customPath = null)
if (fs.existsSync(jsonPath)) if (fs.existsSync(jsonPath))
{ {
obj = JSON.parse(fs.readFileSync(jsonPath, 'utf8')); obj = JSON.parse(fs.readFileSync(jsonPath, 'utf8'));
return obj; if (openReadPerms) fs.chmodSync(jsonPath, 0o755);
} else if (fs.existsSync(alternateJsonPath)) { } else if (fs.existsSync(alternateJsonPath)) {
obj = JSON.parse(fs.readFileSync(alternateJsonPath, 'utf8')); obj = JSON.parse(fs.readFileSync(alternateJsonPath, 'utf8'));
if (openReadPerms) fs.chmodSync(alternateJsonPath, 0o755);
} }
else obj = 0; else obj = 0;
return obj; return obj;
@@ -1000,7 +1005,7 @@ function registerFileDB(full_file_path, type) {
} }
function generateFileObject(id, type) { function generateFileObject(id, type) {
var jsonobj = (type === 'audio') ? getJSONMp3(id) : getJSONMp4(id); var jsonobj = (type === 'audio') ? getJSONMp3(id, true) : getJSONMp4(id, null, true);
if (!jsonobj) { if (!jsonobj) {
return null; return null;
} }