mirror of
https://github.com/rwinkhart/sshyp-labs.git
synced 2026-09-02 15:17:35 -04:00
upgradeRCW: Bump direct dependencies
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/rwinkhart/go-boilerplate/back"
|
||||
"github.com/rwinkhart/go-boilerplate/front"
|
||||
"github.com/rwinkhart/go-boilerplate/other"
|
||||
"github.com/rwinkhart/libmutton/global"
|
||||
"github.com/rwinkhart/libmutton/synccommon"
|
||||
)
|
||||
@@ -38,36 +39,39 @@ func main() {
|
||||
// convert the entries
|
||||
fmt.Print("\nRe-encrypting entries. Please wait; do not force close this process.\n\n")
|
||||
var outputDir = global.EntryRoot + "-new"
|
||||
entries, folders := synccommon.WalkEntryDir()
|
||||
entries, folders, err := synccommon.WalkEntryDir()
|
||||
if err != nil {
|
||||
other.PrintError("Failed to walk entry directory: "+err.Error(), back.ErrorRead)
|
||||
}
|
||||
for _, folder := range folders {
|
||||
err := os.MkdirAll(outputDir+strings.ReplaceAll(folder, "/", global.PathSeparator), 0700)
|
||||
if err != nil {
|
||||
back.PrintError("Failed to create directory: "+err.Error(), back.ErrorWrite, true)
|
||||
other.PrintError("Failed to create directory: "+err.Error(), back.ErrorWrite)
|
||||
}
|
||||
}
|
||||
for _, entry := range entries {
|
||||
oldEncBytes, err := os.ReadFile(global.TargetLocationFormat(entry))
|
||||
if err != nil {
|
||||
back.PrintError("Failed to read file: "+err.Error(), back.ErrorRead, true)
|
||||
other.PrintError("Failed to read file: "+err.Error(), back.ErrorRead)
|
||||
}
|
||||
decBytes, err := oldwrap.Decrypt(oldEncBytes, oldRCWPassphrase)
|
||||
if err != nil {
|
||||
back.PrintError("Failed to decrypt file: "+err.Error(), back.ErrorWrite, true)
|
||||
other.PrintError("Failed to decrypt file: "+err.Error(), back.ErrorWrite)
|
||||
}
|
||||
newEncBytes := newwrap.Encrypt(decBytes, newRCWPassphrase)
|
||||
err = os.WriteFile(outputDir+strings.ReplaceAll(entry, "/", global.PathSeparator), newEncBytes, 0600)
|
||||
if err != nil {
|
||||
back.PrintError("Failed to write to file: "+err.Error(), back.ErrorWrite, true)
|
||||
other.PrintError("Failed to write to file: "+err.Error(), back.ErrorWrite)
|
||||
}
|
||||
}
|
||||
|
||||
// swap the new directory with the old one
|
||||
err := os.Rename(global.EntryRoot, global.EntryRoot+"-old")
|
||||
err = os.Rename(global.EntryRoot, global.EntryRoot+"-old")
|
||||
if err != nil {
|
||||
back.PrintError("Failed to rename old directory: "+err.Error(), back.ErrorWrite, true)
|
||||
other.PrintError("Failed to rename old directory: "+err.Error(), back.ErrorWrite)
|
||||
}
|
||||
err = os.Rename(outputDir, global.EntryRoot)
|
||||
if err != nil {
|
||||
back.PrintError("Failed to rename new directory: "+err.Error(), back.ErrorWrite, true)
|
||||
other.PrintError("Failed to rename new directory: "+err.Error(), back.ErrorWrite)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user