Implement special flags for dump and reset db
This commit is contained in:
@@ -71,3 +71,23 @@ func ResetWhereNecessary(associations map[string]FileCommandAssociation, db DB)
|
||||
log.Debug("Done")
|
||||
return nil
|
||||
}
|
||||
|
||||
func ResetAllFiles(db DB) error {
|
||||
log := cylogger.Default.WithPrefix("ResetAllFiles")
|
||||
log.Debug("Start")
|
||||
fileSnapshots, err := db.GetAllFiles()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Debug("Found %d files in database", len(fileSnapshots))
|
||||
for _, fileSnapshot := range fileSnapshots {
|
||||
log.Debug("Resetting file %q", fileSnapshot.FilePath)
|
||||
err = os.WriteFile(fileSnapshot.FilePath, fileSnapshot.FileData, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Debug("File %q written to disk", fileSnapshot.FilePath)
|
||||
}
|
||||
log.Debug("Done")
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user