Relax folder label restrictions

This commit is contained in:
Jakob Borg 2015-09-24 19:51:59 +02:00
parent 43189dfe3a
commit e0a16e08dd
10 changed files with 32 additions and 31 deletions

View File

@ -401,7 +401,7 @@ func assets() {
}
func xdr() {
runPrint("go", "generate", "./lib/discover", "./lib/db")
runPrint("go", "generate", "./lib/discover", "./lib/db", "./lib/protocol")
}
func translate() {

View File

@ -13,12 +13,11 @@
<div class="col-md-12">
<div class="form-group" ng-class="{'has-error': folderEditor.folderID.$invalid && folderEditor.folderID.$dirty}">
<label for="folderID"><span translate>Folder ID</span></label>
<input name="folderID" ng-readonly="editingExisting" id="folderID" class="form-control" type="text" ng-model="currentFolder.id" required unique-folder ng-pattern="/^[a-zA-Z0-9-_.]{1,64}$/"></input>
<input name="folderID" ng-readonly="editingExisting" id="folderID" class="form-control" type="text" ng-model="currentFolder.id" required unique-folder></input>
<p class="help-block">
<span translate ng-if="folderEditor.folderID.$valid || folderEditor.folderID.$pristine">Short identifier for the folder. Must be the same on all cluster devices.</span>
<span translate ng-if="folderEditor.folderID.$error.uniqueFolder">The folder ID must be unique.</span>
<span translate ng-if="folderEditor.folderID.$error.required && folderEditor.folderID.$dirty">The folder ID cannot be blank.</span>
<span translate ng-if="folderEditor.folderID.$error.pattern && folderEditor.folderID.$dirty">The folder ID must be a short identifier (64 characters or less) consisting of letters, numbers and the dot (.), dash (-) and underscode (_) characters only.</span>
</p>
</div>
<div class="form-group" ng-class="{'has-error': folderEditor.folderPath.$invalid && folderEditor.folderPath.$dirty}">

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
// Copyright (C) 2014 The Protocol Authors.
//go:generate -command genxdr go run ../syncthing/Godeps/_workspace/src/github.com/calmh/xdr/cmd/genxdr/main.go
//go:generate -command genxdr go run ../../Godeps/_workspace/src/github.com/calmh/xdr/cmd/genxdr/main.go
//go:generate genxdr -o message_xdr.go message.go
package protocol
@ -8,7 +8,7 @@ package protocol
import "fmt"
type IndexMessage struct {
Folder string
Folder string // max:256
Files []FileInfo // max:1000000
Flags uint32
Options []Option // max:64
@ -95,7 +95,7 @@ func (b BlockInfo) String() string {
}
type RequestMessage struct {
Folder string // max:64
Folder string // max:256
Name string // max:8192
Offset int64
Size int32
@ -126,7 +126,7 @@ func (o *ClusterConfigMessage) GetOption(key string) string {
}
type Folder struct {
ID string // max:64
ID string // max:256
Devices []Device // max:1000000
Flags uint32
Options []Option // max:64

View File

@ -41,7 +41,7 @@ IndexMessage Structure:
struct IndexMessage {
string Folder<>;
string Folder<256>;
FileInfo Files<1000000>;
unsigned int Flags;
Option Options<64>;
@ -74,6 +74,9 @@ func (o IndexMessage) AppendXDR(bs []byte) ([]byte, error) {
}
func (o IndexMessage) EncodeXDRInto(xw *xdr.Writer) (int, error) {
if l := len(o.Folder); l > 256 {
return xw.Tot(), xdr.ElementSizeExceeded("Folder", l, 256)
}
xw.WriteString(o.Folder)
if l := len(o.Files); l > 1000000 {
return xw.Tot(), xdr.ElementSizeExceeded("Files", l, 1000000)
@ -111,7 +114,7 @@ func (o *IndexMessage) UnmarshalXDR(bs []byte) error {
}
func (o *IndexMessage) DecodeXDRFrom(xr *xdr.Reader) error {
o.Folder = xr.ReadString()
o.Folder = xr.ReadStringMax(256)
_FilesSize := int(xr.ReadUint32())
if _FilesSize < 0 {
return xdr.ElementSizeExceeded("Files", _FilesSize, 1000000)
@ -380,7 +383,7 @@ RequestMessage Structure:
struct RequestMessage {
string Folder<64>;
string Folder<256>;
string Name<8192>;
hyper Offset;
int Size;
@ -416,8 +419,8 @@ func (o RequestMessage) AppendXDR(bs []byte) ([]byte, error) {
}
func (o RequestMessage) EncodeXDRInto(xw *xdr.Writer) (int, error) {
if l := len(o.Folder); l > 64 {
return xw.Tot(), xdr.ElementSizeExceeded("Folder", l, 64)
if l := len(o.Folder); l > 256 {
return xw.Tot(), xdr.ElementSizeExceeded("Folder", l, 256)
}
xw.WriteString(o.Folder)
if l := len(o.Name); l > 8192 {
@ -456,7 +459,7 @@ func (o *RequestMessage) UnmarshalXDR(bs []byte) error {
}
func (o *RequestMessage) DecodeXDRFrom(xr *xdr.Reader) error {
o.Folder = xr.ReadStringMax(64)
o.Folder = xr.ReadStringMax(256)
o.Name = xr.ReadStringMax(8192)
o.Offset = int64(xr.ReadUint64())
o.Size = int32(xr.ReadUint32())
@ -714,7 +717,7 @@ Folder Structure:
struct Folder {
string ID<64>;
string ID<256>;
Device Devices<1000000>;
unsigned int Flags;
Option Options<64>;
@ -747,8 +750,8 @@ func (o Folder) AppendXDR(bs []byte) ([]byte, error) {
}
func (o Folder) EncodeXDRInto(xw *xdr.Writer) (int, error) {
if l := len(o.ID); l > 64 {
return xw.Tot(), xdr.ElementSizeExceeded("ID", l, 64)
if l := len(o.ID); l > 256 {
return xw.Tot(), xdr.ElementSizeExceeded("ID", l, 256)
}
xw.WriteString(o.ID)
if l := len(o.Devices); l > 1000000 {
@ -787,7 +790,7 @@ func (o *Folder) UnmarshalXDR(bs []byte) error {
}
func (o *Folder) DecodeXDRFrom(xr *xdr.Reader) error {
o.ID = xr.ReadStringMax(64)
o.ID = xr.ReadStringMax(256)
_DevicesSize := int(xr.ReadUint32())
if _DevicesSize < 0 {
return xdr.ElementSizeExceeded("Devices", _DevicesSize, 1000000)

View File

@ -172,9 +172,7 @@ func TestClose(t *testing.T) {
func TestElementSizeExceededNested(t *testing.T) {
m := ClusterConfigMessage{
Folders: []Folder{
{ID: "longstringlongstringlongstringinglongstringlongstringlonlongstringlongstringlon"},
},
ClientName: "longstringlongstringlongstringinglongstringlongstringlonlongstringlongstringlon",
}
_, err := m.EncodeXDR(ioutil.Discard)
if err == nil {

View File

@ -226,12 +226,12 @@ func (p *Process) Events(since int) ([]Event, error) {
}
func (p *Process) Rescan(folder string) error {
_, err := p.Post("/rest/db/scan?folder="+folder, nil)
_, err := p.Post("/rest/db/scan?folder="+url.QueryEscape(folder), nil)
return err
}
func (p *Process) RescanDelay(folder string, delaySeconds int) error {
_, err := p.Post(fmt.Sprintf("/rest/db/scan?folder=%s&next=%d", folder, delaySeconds), nil)
_, err := p.Post(fmt.Sprintf("/rest/db/scan?folder=%s&next=%d", url.QueryEscape(folder), delaySeconds), nil)
return err
}
@ -341,7 +341,7 @@ type Model struct {
}
func (p *Process) Model(folder string) (Model, error) {
bs, err := p.Get("/rest/db/status?folder=" + folder)
bs, err := p.Get("/rest/db/status?folder=" + url.QueryEscape(folder))
if err != nil {
return Model{}, err
}

View File

@ -12,7 +12,7 @@
<order>random</order>
<ignoreDelete>false</ignoreDelete>
</folder>
<folder id="s12" path="s12-1" ro="false" rescanIntervalS="10" ignorePerms="false" autoNormalize="true">
<folder id="¯\_(ツ)_/¯ Räksmörgås 动作 Адрес" path="s12-1" ro="false" rescanIntervalS="10" ignorePerms="false" autoNormalize="true">
<device id="I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU"></device>
<device id="JMFJCXB-GZDE4BN-OCJE3VF-65GYZNU-AIVJRET-3J6HMRQ-AUQIGJO-FKNHMQU"></device>
<minDiskFreePct>1</minDiskFreePct>

View File

@ -14,7 +14,7 @@
<ignoreDelete>false</ignoreDelete>
<scanProgressInterval>0</scanProgressInterval>
</folder>
<folder id="s12" path="s12-2" ro="false" rescanIntervalS="15" ignorePerms="false" autoNormalize="true">
<folder id="¯\_(ツ)_/¯ Räksmörgås 动作 Адрес" path="s12-2" ro="false" rescanIntervalS="15" ignorePerms="false" autoNormalize="true">
<device id="I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU"></device>
<device id="JMFJCXB-GZDE4BN-OCJE3VF-65GYZNU-AIVJRET-3J6HMRQ-AUQIGJO-FKNHMQU"></device>
<minDiskFreePct>1</minDiskFreePct>

View File

@ -25,6 +25,7 @@ import (
const (
longTimeLimit = 5 * time.Minute
shortTimeLimit = 45 * time.Second
s12Folder = `¯\_(ツ)_/¯ Räksmörgås 动作 Адрес` // This was renamed to ensure arbitrary folder IDs are fine.
)
func TestSyncClusterWithoutVersioning(t *testing.T) {
@ -220,7 +221,7 @@ func testSyncCluster(t *testing.T) {
t.Fatal(err)
}
if i == 0 || i == 1 {
if err := device.RescanDelay("s12", 86400); err != nil {
if err := device.RescanDelay(s12Folder, 86400); err != nil {
t.Fatal(err)
}
}
@ -418,7 +419,7 @@ func scSyncAndCompare(p []*rc.Process, expected [][]fileInfo) error {
if !rc.InSync("default", p...) {
continue
}
if !rc.InSync("s12", p[0], p[1]) {
if !rc.InSync(s12Folder, p[0], p[1]) {
continue
}
if !rc.InSync("s23", p[1], p[2]) {