mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-26 23:12:09 +02:00
Presaving clean up improvements: Skip presaving empty commands and make timestamp format clearer
This commit is contained in:
parent
328c35a096
commit
30ba0bd35c
@ -99,7 +99,7 @@ func presaveHistoryEntry(ctx context.Context) {
|
|||||||
|
|
||||||
// Augment it with os.Args
|
// Augment it with os.Args
|
||||||
entry.Command = trimTrailingWhitespace(os.Args[3])
|
entry.Command = trimTrailingWhitespace(os.Args[3])
|
||||||
if strings.HasPrefix(" ", entry.Command) {
|
if strings.HasPrefix(" ", entry.Command) || entry.Command == "" {
|
||||||
// Don't save commands that start with a space
|
// Don't save commands that start with a space
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ func saveHistoryEntry(ctx context.Context) {
|
|||||||
// Drop any entries from pre-saving since they're no longer needed
|
// Drop any entries from pre-saving since they're no longer needed
|
||||||
if config.BetaMode {
|
if config.BetaMode {
|
||||||
deletePresavedEntryFunc := func() error {
|
deletePresavedEntryFunc := func() error {
|
||||||
tx, err := lib.MakeWhereQueryFromSearch(ctx, db, "cwd:"+entry.CurrentWorkingDirectory+" start_time:"+strconv.FormatInt(entry.StartTime.Unix(), 10)+" end_time:1970/01/01_00:00:00_+0000")
|
tx, err := lib.MakeWhereQueryFromSearch(ctx, db, "cwd:"+entry.CurrentWorkingDirectory+" start_time:"+strconv.FormatInt(entry.StartTime.Unix(), 10)+" end_time:1970/01/01_00:00:00_+00:00")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to query for pre-saved history entry: %w", err)
|
return fmt.Errorf("failed to query for pre-saved history entry: %w", err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user