Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/lib/helpers/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,32 @@ export enum InvalidFileType {
EXTENSION = 'invalid_extension'
}

/**
* Check if a file is an image based on its MIME type
*/
export function isImageFile(mimeType: string | null | undefined): boolean {
if (!mimeType) return false;
return mimeType.startsWith('image/');
}

/**
* Check if a file is larger than the specified size threshold (in bytes)
*/
export function isLargeFile(fileSize: number, thresholdBytes: number = 1024 * 1024): boolean {
return fileSize > thresholdBytes;
}

/**
* Check if a file is a large image
*/
export function isLargeImage(
mimeType: string | null | undefined,
fileSize: number,
thresholdBytes: number = 1024 * 1024
): boolean {
return isImageFile(mimeType) && isLargeFile(fileSize, thresholdBytes);
}
Comment on lines +100 to +124
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if the new helper functions are used anywhere in the codebase
echo "Searching for usages of isImageFile, isLargeFile, isLargeImage..."
rg -n "isImageFile|isLargeFile|isLargeImage" --type=ts --type=svelte -g '!src/lib/helpers/files.ts'

Repository: appwrite/console

Length of output: 173


🏁 Script executed:

#!/bin/bash
# Check if the new helper functions are used anywhere in the codebase
echo "Searching for usages of isImageFile, isLargeFile, isLargeImage..."
rg -n "isImageFile|isLargeFile|isLargeImage" -g '!src/lib/helpers/files.ts' -g '*.ts' -g '*.tsx' -g '*.js' -g '*.jsx' -g '*.svelte'

Repository: appwrite/console

Length of output: 517


Remove unused helper functions or document their intended purpose.

Verification confirms these functions are exported but have zero external usages in the codebase—only internal usage within isLargeImage. While the implementation follows guidelines (pure functions, camelCase naming), exporting unused code creates maintenance burden.

Either remove isImageFile and isLargeFile if not needed, or add a TODO comment documenting their intended use in future features.

🤖 Prompt for AI Agents
In src/lib/helpers/files.ts around lines 100 to 124, the helper functions
isImageFile and isLargeFile are exported but have no external usages (only used
by isLargeImage); either remove the two unused exports and inline their logic
into isLargeImage (replace calls with direct checks and remove their export
declarations), or keep them and add a single-line TODO comment above each
function documenting intended future use (e.g., "TODO: exported for potential
reuse in X feature — remove if unused by Y date"); ensure exports/exports list
and imports elsewhere are updated accordingly so there are no dangling exports.


export const defaultIgnore = `
### Node ###
# Logs
Expand Down
Loading
Loading