This commit is contained in:
X4Lo committed 2024-06-05 16:53:14 +01:00
commit 710ebcc934
82 files changed
+1422 -386

No files matched your search

+4 -1
View File
@@ -515,7 +515,10 @@ async function refrechEntry(entryId) {
if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' });
const updatedEntry = await Entry.findByPk(entryId, {
include: includes
include: includes,
order: [
[{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list
]
});
const entryData = updatedEntry.get({ plain: true });
+31
View File
@@ -0,0 +1,31 @@
// logService.js
const fs = require('fs');
const util = require('util');
// Convert fs.writeFile to a promise-based function
const writeFile = util.promisify(fs.writeFile);
// Ensure the log file exists and is accessible
const logFilePath = 'showy.log';
fs.open(logFilePath, 'a', (err, fd) => {
if (err) {
console.error("Failed to open log file:", err);
} else {
fs.close(fd, (err) => {
if (err) console.error("Failed to close log file:", err);
});
}
});
// Asynchronous function to append a message to the log file
async function logToFile(message) {
try {
await writeFile(logFilePath, `${message}\n`, { flag: 'a' });
} catch (err) {
console.error("Failed to write to log file:", err);
}
}
module.exports = {
logToFile,
};
+61
View File
@@ -0,0 +1,61 @@
const fs = require('fs');
const path = require('path');
const parrentProcess = JSON.parse(process.env.PARENT_PROCESS || '{}');
let userDataPath = '';
const defaultSettings = {
userDataPath: '',
tmdbApiUrl: '',
tmdbApiKey: '',
frontPort: '',
backPort: '',
portableMode: '',
};
function getUserDataPath() {
// return parrentProcess.electron_path || path.join(__dirname, '..', '..', 'data');
return path.join(__dirname, '..', '..');
}
function getSettingsFilePath() {
return path.join(getUserDataPath(), 'settings.json');
}
function getSettings() {
const settingsFilePath = getSettingsFilePath();
try {
const settingsData = fs.readFileSync(settingsFilePath);
// console.log(`Loaded settings file.`);
return JSON.parse(settingsData);
} catch (err) {
console.error('Error reading settings file:', err);
console.log('Creating default settings file...');
let newSettingsFile = { ...defaultSettings };
let defaultDataPath = path.join(getUserDataPath(), 'data')
newSettingsFile.userDataPath = defaultDataPath;
newSettingsFile.backPort = 4000;
fs.mkdirSync(defaultDataPath, { recursive: true });
fs.writeFileSync(settingsFilePath, JSON.stringify(newSettingsFile, null, 2));
console.log('Default settings file created.');
return defaultSettings;
}
}
function updateSettings(newSettings) {
const settingsFilePath = getSettingsFilePath();
let updatedSettings = { ...userDataPath, ...newSettings };
fs.mkdirSync(newSettings.userDataPath, { recursive: true }); // making sure the newly set data path is created before saving the new config
fs.writeFileSync(settingsFilePath, JSON.stringify(updatedSettings, null, 2));
}
module.exports = {
getSettings,
updateSettings
};