Merge pull request #722 from ente-io/log-to-disk-for-electron
Log to disk for electron
This commit is contained in:
commit
68a2422476
|
@ -49,6 +49,7 @@ import {
|
|||
} from 'utils/upload';
|
||||
import { getUserOwnedCollections } from 'utils/collection';
|
||||
import billingService from 'services/billingService';
|
||||
import { addLogLine } from 'utils/logging';
|
||||
|
||||
const FIRST_ALBUM_NAME = 'My First Album';
|
||||
|
||||
|
@ -426,6 +427,7 @@ export default function Uploader(props: Props) {
|
|||
|
||||
const retryFailed = async () => {
|
||||
try {
|
||||
addLogLine('user retrying failed upload');
|
||||
const filesWithCollections =
|
||||
await uploadManager.getFailedFilesWithCollections();
|
||||
await preUploadAction();
|
||||
|
|
|
@ -14,6 +14,12 @@ class ElectronService {
|
|||
checkIsBundledApp() {
|
||||
return isElectron() && this.isBundledApp;
|
||||
}
|
||||
|
||||
logToDisk(msg: string) {
|
||||
if (this.electronAPIs?.logToDisk) {
|
||||
this.electronAPIs?.logToDisk(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default new ElectronService();
|
||||
|
|
|
@ -141,8 +141,6 @@ class UploadManager {
|
|||
this.metadataAndFileTypeInfoMap
|
||||
);
|
||||
|
||||
addLogLine(`clusterLivePhotoFiles called`);
|
||||
|
||||
// filter out files whose metadata detection failed or those that have been skipped because the files are too large,
|
||||
// as they will be rejected during upload and are not valid upload files which we need to clustering
|
||||
const rejectedFileLocalIDs = new Set(
|
||||
|
@ -167,11 +165,16 @@ class UploadManager {
|
|||
}
|
||||
});
|
||||
|
||||
addLogLine(`clusterLivePhotoFiles started`);
|
||||
|
||||
const analysedMediaFiles =
|
||||
UploadService.clusterLivePhotoFiles(filesWithMetadata);
|
||||
|
||||
addLogLine(`clusterLivePhotoFiles ended`);
|
||||
const allFiles = [...rejectedFiles, ...analysedMediaFiles];
|
||||
|
||||
addLogLine(
|
||||
`got live photos: ${mediaFiles.length !== allFiles.length}`
|
||||
);
|
||||
uiService.setFilenames(
|
||||
new Map<number, string>(
|
||||
allFiles.map((mediaFile) => [
|
||||
|
@ -184,9 +187,6 @@ class UploadManager {
|
|||
UIService.setHasLivePhoto(
|
||||
mediaFiles.length !== allFiles.length
|
||||
);
|
||||
addLogLine(
|
||||
`got live photos: ${mediaFiles.length !== allFiles.length}`
|
||||
);
|
||||
|
||||
await this.uploadMediaFiles(allFiles);
|
||||
}
|
||||
|
@ -261,7 +261,6 @@ class UploadManager {
|
|||
} else {
|
||||
// and don't break for subsequent files just log and move on
|
||||
logError(e, 'parsing failed for a file');
|
||||
}
|
||||
addLogLine(
|
||||
`failed to parse metadata json file ${getFileNameSize(
|
||||
file
|
||||
|
@ -269,6 +268,7 @@ class UploadManager {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (e.message !== CustomError.UPLOAD_CANCELLED) {
|
||||
logError(e, 'error seeding MetadataMap');
|
||||
|
@ -311,13 +311,13 @@ class UploadManager {
|
|||
} else {
|
||||
// and don't break for subsequent files just log and move on
|
||||
logError(e, 'extractFileTypeAndMetadata failed');
|
||||
}
|
||||
addLogLine(
|
||||
`metadata extraction failed ${getFileNameSize(
|
||||
file
|
||||
)} error: ${e.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
this.metadataAndFileTypeInfoMap.set(localID, {
|
||||
fileTypeInfo: fileTypeInfo && { ...fileTypeInfo },
|
||||
metadata: metadata && { ...metadata },
|
||||
|
@ -509,6 +509,7 @@ class UploadManager {
|
|||
}
|
||||
|
||||
public cancelRunningUpload() {
|
||||
addLogLine('user cancelled running upload');
|
||||
UIService.setUploadStage(UPLOAD_STAGES.CANCELLING);
|
||||
uploadCancelService.requestUploadCancelation();
|
||||
}
|
||||
|
|
|
@ -131,7 +131,6 @@ export default async function uploader(
|
|||
backupedFile,
|
||||
encryptedFile.fileKey
|
||||
);
|
||||
addLogLine(`uploadFile ${fileNameSize}`);
|
||||
|
||||
const uploadedFile = await UploadHttpClient.uploadFile(uploadFile);
|
||||
|
||||
|
|
|
@ -62,4 +62,5 @@ export interface ElectronAPIs {
|
|||
getEncryptionKey: () => Promise<string>;
|
||||
openDiskCache: (cacheName: string) => Promise<Cache>;
|
||||
deleteDiskCache: (cacheName: string) => Promise<boolean>;
|
||||
logToDisk: (msg: string) => void;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ import { convertBytesToHumanReadable } from 'utils/file/size';
|
|||
import { formatDateTime } from 'utils/time';
|
||||
import { saveLogLine, getLogs } from 'utils/storage';
|
||||
import { isDEVSentryENV } from 'constants/sentry';
|
||||
import isElectron from 'is-electron';
|
||||
import ElectronService from 'services/electron/common';
|
||||
|
||||
export function addLogLine(log: string) {
|
||||
if (isDEVSentryENV()) {
|
||||
|
@ -12,6 +14,9 @@ export function addLogLine(log: string) {
|
|||
timestamp: Date.now(),
|
||||
logLine: log,
|
||||
});
|
||||
if (isElectron()) {
|
||||
ElectronService.logToDisk(log);
|
||||
}
|
||||
}
|
||||
|
||||
export const addLocalLog = (getLog: () => string) => {
|
||||
|
|
Loading…
Reference in a new issue