Update Tdarr_Plugin_z80t_keep_original_date so works on windows

make-only-subtitle-default
HaveAGitGat 2 years ago
parent cfd357d0ef
commit f3937b9f0c

@ -40,6 +40,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
// eslint-disable-next-line import/no-unresolved,import/no-extraneous-dependencies // eslint-disable-next-line import/no-unresolved,import/no-extraneous-dependencies
const touch = require('touch'); const touch = require('touch');
const os = require('os');
const fs = require('fs');
const log = (msg) => { const log = (msg) => {
if (inputs.log === true) { if (inputs.log === true) {
@ -57,7 +59,20 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
try { try {
log('Changing date...'); log('Changing date...');
if (os.platform() === 'win32') {
fs.utimes(
file._id,
new Date().getTime() / 1000,
otherArguments.originalLibraryFile.statSync.mtimeMs / 1000,
() => {
log('Error updating modified date');
},
);
} else {
touch.sync(file._id, { mtimeMs: otherArguments.originalLibraryFile.statSync.mtimeMs, force: true }); touch.sync(file._id, { mtimeMs: otherArguments.originalLibraryFile.statSync.mtimeMs, force: true });
}
log('Done.'); log('Done.');
responseData.infoLog += 'File timestamps updated or match original file\n'; responseData.infoLog += 'File timestamps updated or match original file\n';
return responseData; return responseData;

Loading…
Cancel
Save