mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
implementing cleaning job for gpx files
This commit is contained in:
parent
baf426ff76
commit
2bb686997e
@ -1,7 +1,7 @@
|
||||
import {NextFunction, Request, Response} from 'express';
|
||||
import * as fs from 'fs';
|
||||
import { Config } from '../../common/config/private/Config';
|
||||
import { GPXProcessing } from '../model/GPXProcessing';
|
||||
import { GPXProcessing } from '../model/fileprocessing/GPXProcessing';
|
||||
|
||||
export class MetaFileMWs {
|
||||
public static async compressGPX(
|
||||
|
@ -1,21 +1,27 @@
|
||||
import * as path from 'path';
|
||||
import {constants as fsConstants, promises as fsp} from 'fs';
|
||||
import * as xml2js from 'xml2js';
|
||||
import {ProjectPath} from '../ProjectPath';
|
||||
import {Config} from '../../common/config/private/Config';
|
||||
import {ProjectPath} from '../../ProjectPath';
|
||||
import {Config} from '../../../common/config/private/Config';
|
||||
import {SupportedFormats} from '../../../common/SupportedFormats';
|
||||
|
||||
type gpxEntry = { '$': { lat: string, lon: string }, ele: string[], time: string[], extensions: unknown };
|
||||
|
||||
export class GPXProcessing {
|
||||
|
||||
public static isMetaFile(fullPath: string): boolean {
|
||||
const extension = path.extname(fullPath).toLowerCase();
|
||||
return SupportedFormats.WithDots.MetaFiles.indexOf(extension) !== -1;
|
||||
}
|
||||
|
||||
public static generateConvertedPath(filePath: string): string {
|
||||
const file = path.basename(filePath);
|
||||
return path.join(
|
||||
ProjectPath.TranscodedFolder,
|
||||
ProjectPath.getRelativePathToImages(path.dirname(filePath)),
|
||||
file
|
||||
);
|
||||
path.basename(filePath)
|
||||
+ '_' + Config.Server.MetaFile.GPXCompressing.minDistance + 'm' +
|
||||
Config.Server.MetaFile.GPXCompressing.minTimeDistance + 'ms' +
|
||||
path.extname(filePath));
|
||||
}
|
||||
|
||||
public static async isValidConvertedPath(
|
||||
@ -25,7 +31,7 @@ export class GPXProcessing {
|
||||
ProjectPath.ImageFolder,
|
||||
path.relative(
|
||||
ProjectPath.TranscodedFolder,
|
||||
convertedPath
|
||||
convertedPath.substring(0, convertedPath.lastIndexOf('_'))
|
||||
)
|
||||
);
|
||||
|
@ -2,7 +2,7 @@ import {Config} from '../../../../common/config/private/Config';
|
||||
import {DefaultsJobs} from '../../../../common/entities/job/JobDTO';
|
||||
import {FileJob} from './FileJob';
|
||||
import {PhotoProcessing} from '../../fileprocessing/PhotoProcessing';
|
||||
import {GPXProcessing} from '../../GPXProcessing';
|
||||
import {GPXProcessing} from '../../fileprocessing/GPXProcessing';
|
||||
import {FileDTO} from '../../../../common/entities/FileDTO';
|
||||
import {Logger} from '../../../Logger';
|
||||
|
||||
|
@ -8,6 +8,8 @@ import { Job } from './Job';
|
||||
import {ProjectPath} from '../../../ProjectPath';
|
||||
import {PhotoProcessing} from '../../fileprocessing/PhotoProcessing';
|
||||
import {VideoProcessing} from '../../fileprocessing/VideoProcessing';
|
||||
import {DiskMangerWorker} from '../../threading/DiskMangerWorker';
|
||||
import {GPXProcessing} from '../../fileprocessing/GPXProcessing';
|
||||
|
||||
export class TempFolderCleaningJob extends Job {
|
||||
public readonly Name = DefaultsJobs[DefaultsJobs['Temp Folder Cleaning']];
|
||||
@ -31,6 +33,10 @@ export class TempFolderCleaningJob extends Job {
|
||||
return VideoProcessing.isValidConvertedPath(filePath);
|
||||
}
|
||||
|
||||
if (GPXProcessing.isMetaFile(filePath)) {
|
||||
return GPXProcessing.isValidConvertedPath(filePath);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -11,10 +11,10 @@ import { VideoDTO } from '../../../common/entities/VideoDTO';
|
||||
import {FileDTO} from '../../../common/entities/FileDTO';
|
||||
import {MetadataLoader} from './MetadataLoader';
|
||||
import {Logger} from '../../Logger';
|
||||
import { SupportedFormats } from '../../../common/SupportedFormats';
|
||||
import {VideoProcessing} from '../fileprocessing/VideoProcessing';
|
||||
import {PhotoProcessing} from '../fileprocessing/PhotoProcessing';
|
||||
import {Utils} from '../../../common/Utils';
|
||||
import {GPXProcessing} from '../fileprocessing/GPXProcessing';
|
||||
|
||||
export class DiskMangerWorker {
|
||||
public static calcLastModified(stat: Stats): number {
|
||||
@ -164,7 +164,7 @@ export class DiskMangerWorker {
|
||||
}
|
||||
)) as SubDirectoryDTO;
|
||||
|
||||
d.lastScanned = 0; // it was not a fully scan
|
||||
d.lastScanned = 0; // it was not a fully scanned
|
||||
d.isPartial = true;
|
||||
|
||||
directory.directories.push(d);
|
||||
@ -223,7 +223,7 @@ export class DiskMangerWorker {
|
||||
e.toString()
|
||||
);
|
||||
}
|
||||
} else if (DiskMangerWorker.isMetaFile(fullFilePath)) {
|
||||
} else if (GPXProcessing.isMetaFile(fullFilePath)) {
|
||||
if (
|
||||
!DiskMangerWorker.isEnabledMetaFile(fullFilePath) ||
|
||||
settings.noMetaFile === true ||
|
||||
@ -243,10 +243,6 @@ export class DiskMangerWorker {
|
||||
return directory;
|
||||
}
|
||||
|
||||
private static isMetaFile(fullPath: string): boolean {
|
||||
const extension = path.extname(fullPath).toLowerCase();
|
||||
return SupportedFormats.WithDots.MetaFiles.indexOf(extension) !== -1;
|
||||
}
|
||||
|
||||
private static isEnabledMetaFile(fullPath: string): boolean {
|
||||
const extension = path.extname(fullPath).toLowerCase();
|
||||
|
Loading…
x
Reference in New Issue
Block a user