Accept versioning data in reports

This commit is contained in:
Jakob Borg 2016-02-15 12:50:00 +01:00
parent 1ded36fcff
commit d884768344

View File

@ -69,6 +69,10 @@ type report struct {
IgnorePerms int IgnorePerms int
IgnoreDelete int IgnoreDelete int
AutoNormalize int AutoNormalize int
SimpleVersioning int
ExternalVersioning int
StaggeredVersioning int
TrashcanVersioning int
} }
DeviceUses struct { DeviceUses struct {
Introducer int Introducer int
@ -126,7 +130,10 @@ func (r *report) FieldPointers() []interface{} {
&r.Announce.DefaultServersDNS, &r.Announce.DefaultServersIP, &r.Announce.DefaultServersDNS, &r.Announce.DefaultServersIP,
&r.Announce.OtherServers, &r.Relays.Enabled, &r.Relays.DefaultServers, &r.Announce.OtherServers, &r.Relays.Enabled, &r.Relays.DefaultServers,
&r.Relays.OtherServers, &r.UsesRateLimit, &r.UpgradeAllowedManual, &r.Relays.OtherServers, &r.UsesRateLimit, &r.UpgradeAllowedManual,
&r.UpgradeAllowedAuto} &r.UpgradeAllowedAuto,
&r.FolderUses.SimpleVersioning, &r.FolderUses.ExternalVersioning,
&r.FolderUses.StaggeredVersioning, &r.FolderUses.TrashcanVersioning,
}
} }
func (r *report) FieldNames() []string { func (r *report) FieldNames() []string {
@ -173,6 +180,11 @@ func (r *report) FieldNames() []string {
"RateLimitEnabled", "RateLimitEnabled",
"UpgradeAllowedManual", "UpgradeAllowedManual",
"UpgradeAllowedAuto", "UpgradeAllowedAuto",
// v0.12.19+
"FolderSimpleVersioning",
"FolderExternalVersioning",
"FolderStaggeredVersioning",
"FolderTrashcanVersioning",
} }
} }
@ -241,7 +253,11 @@ func setupDB(db *sql.DB) error {
ADD COLUMN RelayOtherServers INTEGER NOT NULL DEFAULT 0, ADD COLUMN RelayOtherServers INTEGER NOT NULL DEFAULT 0,
ADD COLUMN RateLimitEnabled BOOLEAN NOT NULL DEFAULT FALSE, ADD COLUMN RateLimitEnabled BOOLEAN NOT NULL DEFAULT FALSE,
ADD COLUMN UpgradeAllowedManual BOOLEAN NOT NULL DEFAULT FALSE, ADD COLUMN UpgradeAllowedManual BOOLEAN NOT NULL DEFAULT FALSE,
ADD COLUMN UpgradeAllowedAuto BOOLEAN NOT NULL DEFAULT FALSE ADD COLUMN UpgradeAllowedAuto BOOLEAN NOT NULL DEFAULT FALSE,
ADD COLUMN FolderSimpleVersioning INTEGER NOT NULL DEFAULT 0,
ADD COLUMN FolderExternalVersioning INTEGER NOT NULL DEFAULT 0,
ADD COLUMN FolderStaggeredVersioning INTEGER NOT NULL DEFAULT 0,
ADD COLUMN FolderTrashcanVersioning INTEGER NOT NULL DEFAULT 0
`) `)
if err != nil { if err != nil {
return err return err
@ -482,6 +498,10 @@ func getReport(db *sql.DB) map[string]interface{} {
"Folders, ignore deletes": 0, "Folders, ignore deletes": 0,
"Folders, ignore permissions": 0, "Folders, ignore permissions": 0,
"Folders, master mode": 0, "Folders, master mode": 0,
"Folders, simple versioning": 0,
"Folders, external versioning": 0,
"Folders, staggered versioning": 0,
"Folders, trashcan versioning": 0,
"Devices, compress always": 0, "Devices, compress always": 0,
"Devices, compress metadata": 0, "Devices, compress metadata": 0,
"Devices, compress nothing": 0, "Devices, compress nothing": 0,
@ -578,6 +598,18 @@ func getReport(db *sql.DB) map[string]interface{} {
if rep.FolderUses.ReadOnly > 0 { if rep.FolderUses.ReadOnly > 0 {
features["Folders, master mode"]++ features["Folders, master mode"]++
} }
if rep.FolderUses.SimpleVersioning > 0 {
features["Folders, simple versioning"]++
}
if rep.FolderUses.ExternalVersioning > 0 {
features["Folders, external versioning"]++
}
if rep.FolderUses.StaggeredVersioning > 0 {
features["Folders, staggered versioning"]++
}
if rep.FolderUses.TrashcanVersioning > 0 {
features["Folders, trashcan versioning"]++
}
if rep.DeviceUses.CompressAlways > 0 { if rep.DeviceUses.CompressAlways > 0 {
features["Devices, compress always"]++ features["Devices, compress always"]++
} }
@ -894,5 +926,8 @@ func (l sortableFeatureList) Swap(a, b int) {
l[a], l[b] = l[b], l[a] l[a], l[b] = l[b], l[a]
} }
func (l sortableFeatureList) Less(a, b int) bool { func (l sortableFeatureList) Less(a, b int) bool {
if l[a].Pct != l[b].Pct {
return l[a].Pct < l[b].Pct return l[a].Pct < l[b].Pct
} }
return l[a].Key > l[b].Key
}