mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-16 01:59:29 +02:00
Allow specifying --timestamp 0
This commit is contained in:
parent
2307e6247b
commit
e7d596b4e0
2 changed files with 8 additions and 4 deletions
|
@ -17,6 +17,8 @@ Scotty. If not, see <https://www.gnu.org/licenses/>.
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.uploadedlobster.com/scotty/internal/backends"
|
"go.uploadedlobster.com/scotty/internal/backends"
|
||||||
"go.uploadedlobster.com/scotty/internal/cli"
|
"go.uploadedlobster.com/scotty/internal/cli"
|
||||||
|
@ -58,5 +60,5 @@ func init() {
|
||||||
// Cobra supports local flags which will only run when this command
|
// Cobra supports local flags which will only run when this command
|
||||||
// is called directly, e.g.:
|
// is called directly, e.g.:
|
||||||
// beamListensCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
// beamListensCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||||
beamListensCmd.Flags().Int64P("timestamp", "t", 0, "Only import listens newer then given Unix timestamp")
|
beamListensCmd.Flags().Int64P("timestamp", "t", math.MinInt64, "Only import listens newer then given Unix timestamp")
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -153,12 +154,13 @@ func (c *TransferCmd[E, I, R]) Transfer(exp backends.ExportProcessor[R], imp bac
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TransferCmd[E, I, R]) timestamp() (time.Time, error) {
|
func (c *TransferCmd[E, I, R]) timestamp() (time.Time, error) {
|
||||||
timestamp := time.Unix(getInt64FromFlag(c.cmd, "timestamp"), 0)
|
flagValue, err := c.cmd.Flags().GetInt64("timestamp")
|
||||||
if timestamp == time.Unix(0, 0) {
|
if err == nil && flagValue > math.MinInt64 {
|
||||||
|
return time.Unix(flagValue, 0), nil
|
||||||
|
} else {
|
||||||
timestamp, err := c.db.GetImportTimestamp(c.sourceName, c.targetName, c.entity)
|
timestamp, err := c.db.GetImportTimestamp(c.sourceName, c.targetName, c.entity)
|
||||||
return timestamp, err
|
return timestamp, err
|
||||||
}
|
}
|
||||||
return timestamp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TransferCmd[E, I, R]) updateTimestamp(result models.ImportResult, oldTimestamp time.Time) error {
|
func (c *TransferCmd[E, I, R]) updateTimestamp(result models.ImportResult, oldTimestamp time.Time) error {
|
||||||
|
|
Loading…
Add table
Reference in a new issue