cmd/ursrv: Handle send only / recv only accounting correctly

This commit is contained in:
Jakob Borg 2018-09-09 15:39:54 +02:00
parent 0a29fa65ab
commit ae76f1e999

View File

@ -118,7 +118,8 @@ type report struct {
URVersion int
NumCPU int
FolderUses struct {
ReadOnly int
SendOnly int
ReceiveOnly int
IgnorePerms int
IgnoreDelete int
AutoNormalize int
@ -263,7 +264,7 @@ func (r *report) FieldPointers() []interface{} {
&r.TotMiB, &r.FolderMaxMiB, &r.MemoryUsageMiB, &r.SHA256Perf,
&r.MemorySize, &r.Date,
// V2
&r.URVersion, &r.NumCPU, &r.FolderUses.ReadOnly, &r.FolderUses.IgnorePerms,
&r.URVersion, &r.NumCPU, &r.FolderUses.SendOnly, &r.FolderUses.IgnorePerms,
&r.FolderUses.IgnoreDelete, &r.FolderUses.AutoNormalize, &r.DeviceUses.Introducer,
&r.DeviceUses.CustomCertName, &r.DeviceUses.CompressAlways,
&r.DeviceUses.CompressMetadata, &r.DeviceUses.CompressNever,
@ -314,6 +315,9 @@ func (r *report) FieldPointers() []interface{} {
// V3 added late in the RC
&r.WeakHashEnabled,
&r.Address,
// Receive only folders
&r.FolderUses.ReceiveOnly,
}
}
@ -434,6 +438,9 @@ func (r *report) FieldNames() []string {
// V3 added late in the RC
"WeakHashEnabled",
"Address",
// Receive only folders
"FolderRecvOnly",
}
}
@ -621,6 +628,19 @@ func setupDB(db *sql.DB) error {
}
}
// Receive only added ad-hoc
row = db.QueryRow(`SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'reports') AND attname = 'folderrecvonly'`)
if err := row.Scan(&t); err != nil {
// The RecvOnly column doesn't exist; add it.
_, err = db.Exec(`ALTER TABLE Reports
ADD COLUMN FolderRecvOnly INTEGER NOT NULL DEFAULT 0
`)
if err != nil {
return err
}
}
return nil
}
@ -1098,7 +1118,8 @@ func getReport(db *sql.DB) map[string]interface{} {
inc(features["Folder"]["v2"], "Automatic normalization", rep.FolderUses.AutoNormalize)
inc(features["Folder"]["v2"], "Ignore deletes", rep.FolderUses.IgnoreDelete)
inc(features["Folder"]["v2"], "Ignore permissions", rep.FolderUses.IgnorePerms)
inc(features["Folder"]["v2"], "Mode, send-only", rep.FolderUses.ReadOnly)
inc(features["Folder"]["v2"], "Mode, send only", rep.FolderUses.SendOnly)
inc(features["Folder"]["v2"], "Mode, receive only", rep.FolderUses.ReceiveOnly)
add(featureGroups["Folder"]["v2"], "Versioning", "Simple", rep.FolderUses.SimpleVersioning)
add(featureGroups["Folder"]["v2"], "Versioning", "External", rep.FolderUses.ExternalVersioning)