mirror of
https://github.com/kopia/kopia.git
synced 2026-05-10 07:44:01 -04:00
refactor(general): omitzero JSON tag (#4907)
* remove omitempty from object id fields * remove omitempty from storage stats fields * use omitzero for other structs * remove `omitempty` from `UpgradeLockIntent` fields The `omitempty` JSON tag is ineffective for fields of type `Time` and `Duration`. Also, this struct is only used during the "upgrade" protocol, and it is OK to explicitly serialize 0 values, as it was done before.
This commit is contained in:
@@ -12,7 +12,7 @@ type Options struct {
|
||||
RCloneExe string `json:"rcloneExe,omitempty"` // path to rclone executable
|
||||
RCloneArgs []string `json:"rcloneArgs,omitempty"` // additional rclone arguments
|
||||
RCloneEnv []string `json:"rcloneEnv,omitempty"` // additional rclone environment variables
|
||||
StartupTimeout jsonencoding.Duration `json:"startupTimeout,omitempty"` // time to wait for rclone to start
|
||||
StartupTimeout jsonencoding.Duration `json:"startupTimeout,omitzero"` // time to wait for rclone to start
|
||||
Debug bool `json:"debug,omitempty"` // log rclone output
|
||||
NoWaitForTransfers bool `json:"noWaitForTransfers,omitempty"` // when set to true, don't wait for transfers to finish when closing
|
||||
EmbeddedConfig string `json:"embeddedConfig,omitempty"`
|
||||
|
||||
@@ -63,10 +63,10 @@ func (f *ContentFormat) SupportsPasswordChange() bool {
|
||||
// MutableParameters represents parameters of the content manager that can be mutated after the repository
|
||||
// is created.
|
||||
type MutableParameters struct {
|
||||
Version Version `json:"version,omitempty"` // version number, must be "1", "2" or "3"
|
||||
MaxPackSize int `json:"maxPackSize,omitempty"` // maximum size of a pack object
|
||||
IndexVersion int `json:"indexVersion,omitempty"` // force particular index format version (1,2,..)
|
||||
EpochParameters epoch.Parameters `json:"epochParameters,omitempty"` // epoch manager parameters
|
||||
Version Version `json:"version,omitempty"` // version number, must be "1", "2" or "3"
|
||||
MaxPackSize int `json:"maxPackSize,omitempty"` // maximum size of a pack object
|
||||
IndexVersion int `json:"indexVersion,omitempty"` // force particular index format version (1,2,..)
|
||||
EpochParameters epoch.Parameters `json:"epochParameters,omitzero"` // epoch manager parameters
|
||||
}
|
||||
|
||||
// Validate validates the parameters.
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
// repository.
|
||||
type UpgradeLockIntent struct {
|
||||
OwnerID string `json:"ownerID,omitempty"`
|
||||
CreationTime time.Time `json:"creationTime,omitempty"`
|
||||
AdvanceNoticeDuration time.Duration `json:"advanceNoticeDuration,omitempty"`
|
||||
IODrainTimeout time.Duration `json:"ioDrainTimeout,omitempty"`
|
||||
StatusPollInterval time.Duration `json:"statusPollInterval,omitempty"`
|
||||
CreationTime time.Time `json:"creationTime"`
|
||||
AdvanceNoticeDuration time.Duration `json:"advanceNoticeDuration"`
|
||||
IODrainTimeout time.Duration `json:"ioDrainTimeout"`
|
||||
StatusPollInterval time.Duration `json:"statusPollInterval"`
|
||||
Message string `json:"message,omitempty"`
|
||||
MaxPermittedClockDrift time.Duration `json:"maxPermittedClockDrift,omitempty"`
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
type IndirectObjectEntry struct {
|
||||
Start int64 `json:"s,omitempty"`
|
||||
Length int64 `json:"l,omitempty"`
|
||||
Object ID `json:"o,omitempty"`
|
||||
Object ID `json:"o"`
|
||||
}
|
||||
|
||||
func (i *IndirectObjectEntry) endOffset() int64 {
|
||||
|
||||
@@ -126,7 +126,7 @@ type DirEntry struct {
|
||||
ModTime fs.UTCTimestamp `json:"mtime,omitempty"`
|
||||
UserID uint32 `json:"uid,omitempty"`
|
||||
GroupID uint32 `json:"gid,omitempty"`
|
||||
ObjectID object.ID `json:"obj,omitempty"`
|
||||
ObjectID object.ID `json:"obj"`
|
||||
DirSummary *fs.DirectorySummary `json:"summ,omitempty"`
|
||||
}
|
||||
|
||||
@@ -187,8 +187,8 @@ func (m *Manifest) Clone() *Manifest {
|
||||
type StorageStats struct {
|
||||
// amount of new unique data in this snapshot that wasn't there before.
|
||||
// note that this depends on ordering of snapshots.
|
||||
NewData StorageUsageDetails `json:"newData,omitempty"`
|
||||
RunningTotal StorageUsageDetails `json:"runningTotal,omitempty"`
|
||||
NewData StorageUsageDetails `json:"newData"`
|
||||
RunningTotal StorageUsageDetails `json:"runningTotal"`
|
||||
}
|
||||
|
||||
// StorageUsageDetails provides details about snapshot storage usage.
|
||||
|
||||
Reference in New Issue
Block a user