Skip to content

Commit

Permalink
Log failing icon extraction in MacOsApplicationRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverschwendener committed Mar 5, 2024
1 parent f923aeb commit db3d519
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
Binary file not shown.
2 changes: 0 additions & 2 deletions src/main/Core/ImageGenerator/ImageGeneratorModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ export class ImageGeneratorModule {
new MacOsApplicationIconExtractor(
dependencyRegistry.get("FileSystemUtility"),
dependencyRegistry.get("CommandlineUtility"),
dependencyRegistry.get("AssetPathResolver"),
dependencyRegistry.get("Logger"),
cacheFileNameGenerator,
cacheFolderPath,
),
Expand Down
14 changes: 1 addition & 13 deletions src/main/Core/ImageGenerator/MacOsApplicationIconExtractor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { AssetPathResolver } from "@Core/AssetPathResolver";
import type { CommandlineUtility } from "@Core/CommandlineUtility";
import type { FileSystemUtility } from "@Core/FileSystemUtility";
import type { Logger } from "@Core/Logger";
import type { Image } from "@common/Core/Image";
import { join } from "path";
import type { CacheFileNameGenerator } from "./CacheFileNameGenerator";
Expand All @@ -11,8 +9,6 @@ export class MacOsApplicationIconExtractor implements FileIconExtractor {
public constructor(
private readonly fileSystemUtility: FileSystemUtility,
private readonly commandlineUtility: CommandlineUtility,
private readonly assetPathResolver: AssetPathResolver,
private readonly logger: Logger,
private readonly cacheFileNameGenerator: CacheFileNameGenerator,
private readonly cacheFolder: string,
) {}
Expand Down Expand Up @@ -49,15 +45,7 @@ export class MacOsApplicationIconExtractor implements FileIconExtractor {
const iconFileAlreadyExists = await this.fileSystemUtility.pathExists(iconFilePath);

if (!iconFileAlreadyExists) {
try {
await this.generateAppIcon(applicationFilePath, iconFilePath);
} catch (error) {
this.logger.warn(
`Unable to generate app icon for "${applicationFilePath}". Reason: ${error}. Using generic app icon instead.`,
);

return this.assetPathResolver.getModuleAssetPath("FileImageGenerator", "GenericApplicationIcon.png");
}
await this.generateAppIcon(applicationFilePath, iconFilePath);
}

return iconFilePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@ export class MacOsApplicationRepository implements ApplicationRepository {
const filePaths = await this.getAllFilePaths();
const icons = await this.fileImageGenerator.getImages(filePaths);

return filePaths
.filter((filePath) => !!icons[filePath])
.map((filePath) => {
const icon = icons[filePath];
return filePaths.map((filePath) => {
const icon = icons[filePath];

if (!icon) {
this.logger.warn(`Failed to generate icon for "${filePath}". Using generic icon instead.`);
}
if (!icon) {
console.log(filePath);
this.logger.warn(`Failed to generate icon for "${filePath}". Using generic icon instead.`);
}

return new Application(parse(filePath).name, filePath, icon ?? this.getGenericAppIcon());
});
return new Application(parse(filePath).name, filePath, icon ?? this.getGenericAppIcon());
});
}

private async getAllFilePaths(): Promise<string[]> {
Expand Down

0 comments on commit db3d519

Please sign in to comment.