-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SMM2->3 migration modal, new user modal, disk space warning, markdown…
… format annoucements (#224)
- Loading branch information
Showing
14 changed files
with
444 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package migration | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"log/slog" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/spf13/viper" | ||
) | ||
|
||
type migration struct { | ||
smm2Dir string | ||
migrationSuccessMarkerPath string | ||
} | ||
|
||
var Migration *migration | ||
|
||
func Init() { | ||
if Migration == nil { | ||
Migration = &migration{} | ||
Migration.smm2Dir = filepath.Join(viper.GetString("smm-local-dir"), "profiles") | ||
Migration.migrationSuccessMarkerPath = filepath.Join(Migration.smm2Dir, migrationSuccessMarkerFile) | ||
} | ||
} | ||
|
||
const migrationSuccessMarkerFile = ".smm3_migration_acknowledged" | ||
|
||
// https://stackoverflow.com/questions/12518876/how-to-check-if-a-file-exists-in-go | ||
func pathExists(path string) bool { | ||
if _, err := os.Stat(path); err == nil { | ||
return true | ||
} else if errors.Is(err, os.ErrNotExist) { | ||
return false | ||
} else { | ||
slog.Warn("Error when checking path exists, so assuming it does not exist: "+path, slog.Any("error", err)) | ||
return false | ||
} | ||
} | ||
|
||
func (m *migration) NeedsSmm2Migration() bool { | ||
if pathExists(m.smm2Dir) { | ||
return !pathExists(Migration.migrationSuccessMarkerPath) | ||
} | ||
return false | ||
} | ||
|
||
func (m *migration) MarkSmm2MigrationSuccess() error { | ||
file, err := os.Create(Migration.migrationSuccessMarkerPath) | ||
if err != nil { | ||
return fmt.Errorf("failed to create migration success marker file: %w", err) | ||
} | ||
err = file.Close() | ||
if err != nil { | ||
return fmt.Errorf("failed to close file: %w", err) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
"Maximised", | ||
"Minimised", | ||
"mircearoata", | ||
"noclose", | ||
"Nyan", | ||
"smmanager", | ||
"smmprofile", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.