mirror of
https://github.com/gtsteffaniak/filebrowser.git
synced 2026-11-26 08:29:41 -05:00
+10








3c02eedca6
Co-authored-by: Kevin B. <kurami32_kbm@proton.me> Co-authored-by: Gabriel Górski <me@glaeqen.eu> Co-authored-by: Joel Godfrey <82655889+BaccanoMob@users.noreply.github.com> Co-authored-by: Shane Chiu <71911511+pwn2ooown@users.noreply.github.com> Co-authored-by: carloda <35763669+carloda@users.noreply.github.com> Co-authored-by: Taufik Hidayat <taufikdev88@gmail.com> Co-authored-by: Stephan Paternotte <Stephan-P@users.noreply.github.com> Co-authored-by: SIDDHU SINGH <siddhu3116@gmail.com> Co-authored-by: Gaurav Kalal <117557391+Gorupa@users.noreply.github.com> Co-authored-by: Nebula <40148908+nebula-it@users.noreply.github.com> Co-authored-by: Juan Soler <juansoler@gmail.com> Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com> Co-authored-by: Anatolii Prylutskyi <anpryl@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Graham Steffaniak <graham@debian-lake.ghome.net> Co-authored-by: Neil <kylelzzz02@icloud.com> Co-authored-by: Graham <info@quantumx-apps.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package cmd
|
|
|
|
import (
|
|
"github.com/gtsteffaniak/filebrowser/backend/internal/database/share"
|
|
"github.com/gtsteffaniak/filebrowser/backend/internal/database/users"
|
|
"github.com/gtsteffaniak/filebrowser/backend/internal/state"
|
|
"github.com/gtsteffaniak/go-logger/logger"
|
|
)
|
|
|
|
// validateShareInfo migrates share links to add default sidebar links
|
|
func validateShareInfo() {
|
|
shares, err := state.GetAllShares()
|
|
if err != nil {
|
|
logger.Debugf("No shares found or error getting shares: %v", err)
|
|
return
|
|
}
|
|
|
|
migratedCount := 0
|
|
for _, link := range shares {
|
|
// Check if this share needs migration (version not set or 0)
|
|
if link.Version == 0 {
|
|
hash := link.Hash
|
|
// Save the updated share
|
|
if err := state.UpdateShare(hash, func(existingShare *share.Share) error {
|
|
// Set version to 1 to indicate migration is complete
|
|
existingShare.Version = 1
|
|
// Add default sidebar links
|
|
existingShare.SidebarLinks = []users.SidebarLink{
|
|
{
|
|
Name: "Share QR Code and Info",
|
|
Category: "shareInfo",
|
|
Target: "#",
|
|
Icon: "qr_code",
|
|
},
|
|
{
|
|
Name: "Download",
|
|
Category: "download",
|
|
Target: "#",
|
|
Icon: "download",
|
|
},
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
logger.Errorf("Failed to migrate share %s: %v", link.Hash, err)
|
|
continue
|
|
}
|
|
|
|
migratedCount++
|
|
}
|
|
}
|
|
|
|
if migratedCount > 0 {
|
|
logger.Infof("Migrated %d share links with default sidebar links", migratedCount)
|
|
}
|
|
}
|