Update deps#253
Conversation
…ind CSS v4 code highlighting style issue
…fication, and walk performance
Reviewer's GuideThis PR upgrades Tailwind and various Go and JS dependencies, refactors markdown processing into smaller functions with safer slug generation and translation handling, hardens database updates and CLI commands, and refreshes RSS/sitemap generation and front-end build/configuration. Sequence diagram for markdown processing pipelinesequenceDiagram
actor Dev
participant Main as generate_main
participant PMF as processMarkdownFile
participant Parse as parseMarkdown
participant Meta as fillMissingMetadata
participant Save as saveMarkdownWithMetadata
participant Update as updatePostAndTranslate
Dev->>Main: generate_main()
Main->>PMF: processMarkdownFile(gc, path)
PMF->>PMF: os.ReadFile(path) / normalize
PMF->>Parse: parseMarkdown(path, data)
Parse-->>PMF: *types.Document
PMF->>Meta: fillMissingMetadata(ctx, doc, path)
Meta-->>PMF: error?
PMF->>Save: saveMarkdownWithMetadata(path, doc)
Save-->>PMF: error?
PMF->>Update: updatePostAndTranslate(gc, doc, path)
Update-->>PMF: error?
PMF-->>Main: *types.Document
Sequence diagram for translation and evaluation of a postsequenceDiagram
participant Gen as translateLang
participant TAE as translateAndEvaluate
participant LLM as translate.Translate
participant Eval as evaluate.EvaluateTranslation
Gen->>TAE: translateAndEvaluate(ctx, post, lang, name, "title", title)
TAE->>LLM: Translate(ctx, llmModel, text, fullLangName)
LLM-->>TAE: translatedText
TAE->>Eval: EvaluateTranslation(ctx, llmModel, post.Main.Metadata.Language, lang, text, translatedText)
Eval-->>TAE: score
alt score < 0.7
TAE-->>Gen: ErrLowQualityTranslation
else score >= 0.7
TAE-->>Gen: translatedText
end
Gen->>TAE: translateAndEvaluate(..., "description", description)
Gen->>TAE: translateAndEvaluate(..., "content", origDocument)
Gen-->>Gen: build translated metadata & markdown
Sequence diagram for CLI command argument handlingsequenceDiagram
actor User
participant Main as main
participant RL as remove_lang_main
User->>Main: website remove_lang <postID> <lang>
Main->>Main: validate os.Args length
alt missing args
Main->>Main: log.Error("missing arguments")
Main->>Main: printUsage()
Main->>Main: os.Exit(1)
else valid args
Main->>RL: remove_lang_main(postID, lang)
RL->>RL: initializeDatabase(dbFile)
RL->>RL: lookup ds.Posts[postID]
RL->>RL: delete(post.Translated, lang)
RL->>RL: updateDatabase(dbFile, ds)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
Fixed security issues:
-
golang.org/x/crypto (link)
-
golang.org/x/net (link)
-
google.golang.org/grpc (link)
-
package-lock.json (link)
-
In generateLocalFeed, post.Translated is now indexed with string(lang) instead of lang (types.Lang); unless the map key type was changed elsewhere, this will break lookups and should be aligned with the actual key type.
-
updateDatabase now defers removal of the tmp file and also explicitly closes/syncs before rename, but the defer will still remove the tmp file after a successful rename; consider only deleting on error to avoid removing the new file on platforms where rename doesn’t fully replace atomically.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In generateLocalFeed, post.Translated is now indexed with string(lang) instead of lang (types.Lang); unless the map key type was changed elsewhere, this will break lookups and should be aligned with the actual key type.
- updateDatabase now defers removal of the tmp file and also explicitly closes/syncs before rename, but the defer will still remove the tmp file after a successful rename; consider only deleting on error to avoid removing the new file on platforms where rename doesn’t fully replace atomically.
## Individual Comments
### Comment 1
<location path="database.go" line_range="78" />
<code_context>
func updateDatabase(dbFile string, ds *DataStore) error {
- f, err := os.OpenFile(dbFile+".tmp", os.O_CREATE|os.O_RDWR|os.O_TRUNC|os.O_EXCL, 0644)
+ tmpFile := dbFile + ".tmp"
+ f, err := os.OpenFile(tmpFile, os.O_CREATE|os.O_RDWR|os.O_TRUNC|os.O_EXCL, 0644)
if err != nil {
</code_context>
<issue_to_address>
**issue (bug_risk):** The deferred removal of the temp file can hide data if os.Rename fails and is unnecessary on success.
In `updateDatabase`, the deferred `os.Remove(tmpFile)` runs regardless of whether `os.Rename` succeeds. If `os.Rename` fails (e.g., permissions, concurrent access), the temp file containing the compressed database is deleted, losing potentially useful data for recovery or debugging. On success, the remove is unnecessary because the path is replaced by the renamed file. Consider removing the deferred `os.Remove` and instead only deleting the temp file after a successful rename, or retaining it on failure so callers can inspect or retry.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| func updateDatabase(dbFile string, ds *DataStore) error { | ||
| f, err := os.OpenFile(dbFile+".tmp", os.O_CREATE|os.O_RDWR|os.O_TRUNC|os.O_EXCL, 0644) | ||
| tmpFile := dbFile + ".tmp" |
There was a problem hiding this comment.
issue (bug_risk): The deferred removal of the temp file can hide data if os.Rename fails and is unnecessary on success.
In updateDatabase, the deferred os.Remove(tmpFile) runs regardless of whether os.Rename succeeds. If os.Rename fails (e.g., permissions, concurrent access), the temp file containing the compressed database is deleted, losing potentially useful data for recovery or debugging. On success, the remove is unnecessary because the path is replaced by the renamed file. Consider removing the deferred os.Remove and instead only deleting the temp file after a successful rename, or retaining it on failure so callers can inspect or retry.
There was a problem hiding this comment.
Code Review
This pull request updates the project's build and dependency configuration by migrating from Bun to npm, upgrading Go and npm dependencies (including Tailwind CSS to v4), and regenerating the templ view files. It also refactors several Go files to improve code quality, such as extracting translation logic, cleaning up database file handling, and simplifying path generation with regular expressions. The review feedback highlights two key improvement opportunities: removing an unnecessary database write operation in get_translation_main to prevent redundant disk I/O, and replacing a fragile strings.TrimPrefix path manipulation with filepath.Rel to ensure robust, cross-platform path resolution.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| err = updateDatabase(dbFile, ds) | ||
| if err != nil { | ||
| log.Fatal().Err(err).Msgf("failed to update database file %s", dbFile) | ||
| } | ||
| } |
There was a problem hiding this comment.
| relPath := strings.TrimPrefix(path, src) | ||
| dstPath := filepath.Join(dst, relPath) |
There was a problem hiding this comment.
Using strings.TrimPrefix(path, src) to determine the relative path can be fragile and error-prone, especially on Windows where path separators differ (\ vs /). If src contains a trailing slash or uses a different separator style, the prefix match might fail entirely, leading to incorrect destination paths.
Using filepath.Rel(src, path) is the standard, robust, and cross-platform way to compute relative paths in Go.
relPath, err := filepath.Rel(src, path)
if err != nil {
return err
}
dstPath := filepath.Join(dst, relPath)
Summary by Sourcery
Upgrade Tailwind CSS and related frontend tooling, refresh generated styles, and refactor markdown and translation handling for improved robustness and maintainability.
New Features:
Enhancements:
Build:
Documentation: