mirror of
https://github.com/syncthing/syncthing.git
synced 2026-01-07 13:29:11 -05:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5980952495 | ||
|
|
618c376e18 | ||
|
|
d31a126408 | ||
|
|
6d3f8a2c06 | ||
|
|
b1ba976122 |
22
CONTRIBUTING.md
Normal file
22
CONTRIBUTING.md
Normal file
@@ -0,0 +1,22 @@
|
||||
Please do contribute!
|
||||
|
||||
## Building
|
||||
|
||||
[See the wiki](https://github.com/calmh/syncthing/wiki/Building)
|
||||
|
||||
## Tests
|
||||
|
||||
Yes please!
|
||||
|
||||
## Style
|
||||
|
||||
`go fmt`
|
||||
|
||||
## Documentation
|
||||
|
||||
[Hack it here](https://github.com/calmh/syncthing/wiki)
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
5
auto/gui.files.go
Normal file
5
auto/gui.files.go
Normal file
File diff suppressed because one or more lines are too long
2
build.sh
2
build.sh
@@ -11,7 +11,7 @@ fi
|
||||
if [[ -z $1 ]] ; then
|
||||
go build -ldflags "-X main.Version $version"
|
||||
elif [[ $1 == "embed" ]] ; then
|
||||
embedder main gui > gui.files.go \
|
||||
embedder auto gui > auto/gui.files.go \
|
||||
&& go build -ldflags "-X main.Version $version"
|
||||
elif [[ $1 == "tar" ]] ; then
|
||||
go build -ldflags "-X main.Version $version" \
|
||||
|
||||
@@ -20,7 +20,7 @@ type Options struct {
|
||||
ExternalServer string `ini:"global-announce-server" default:"syncthing.nym.se:22025" description:"Global server for announcements"`
|
||||
ExternalDiscovery bool `ini:"global-announce-enabled" default:"true" description:"Announce to the global announce server"`
|
||||
LocalDiscovery bool `ini:"local-announce-enabled" default:"true" description:"Announce to the local network"`
|
||||
RequestsInFlight int `ini:"parallell-requests" default:"16" description:"Maximum number of blocks to request in parallell"`
|
||||
ParallelRequests int `ini:"parallel-requests" default:"16" description:"Maximum number of blocks to request in parallel"`
|
||||
LimitRate int `ini:"max-send-kbps" description:"Limit outgoing data rate (kbyte/s)"`
|
||||
ScanInterval time.Duration `ini:"rescan-interval" default:"60s" description:"Scan repository for changes this often"`
|
||||
ConnInterval time.Duration `ini:"reconnection-interval" default:"60s" description:"Attempt to (re)connect to peers this often"`
|
||||
|
||||
File diff suppressed because one or more lines are too long
3
gui.go
3
gui.go
@@ -11,6 +11,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/calmh/syncthing/auto"
|
||||
"github.com/calmh/syncthing/model"
|
||||
"github.com/codegangsta/martini"
|
||||
"github.com/cratonica/embed"
|
||||
@@ -26,7 +27,7 @@ func startGUI(addr string, m *model.Model) {
|
||||
router.Get("/rest/need", restGetNeed)
|
||||
router.Get("/rest/system", restGetSystem)
|
||||
|
||||
fs, err := embed.Unpack(Resources)
|
||||
fs, err := embed.Unpack(auto.Resources)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ go build genfiles.go
|
||||
go build md5r.go
|
||||
|
||||
echo "Setting up (keys)..."
|
||||
i1=$(syncthing -c conf-1 2>&1 | awk '/My ID/ {print $6}')
|
||||
i1=$(syncthing --home conf-1 2>&1 | awk '/My ID/ {print $7}')
|
||||
echo $i1
|
||||
i2=$(syncthing -c conf-2 2>&1 | awk '/My ID/ {print $6}')
|
||||
i2=$(syncthing --home conf-2 2>&1 | awk '/My ID/ {print $7}')
|
||||
echo $i2
|
||||
i3=$(syncthing -c conf-3 2>&1 | awk '/My ID/ {print $6}')
|
||||
i3=$(syncthing --home conf-3 2>&1 | awk '/My ID/ {print $7}')
|
||||
echo $i3
|
||||
|
||||
echo "Setting up (files)..."
|
||||
@@ -26,11 +26,16 @@ dir = $p/files-$i
|
||||
$i1 = 127.0.0.1:22001
|
||||
$i2 = 127.0.0.1:22002
|
||||
$i3 = 127.0.0.1:22003
|
||||
|
||||
[settings]
|
||||
gui-enabled = false
|
||||
listen-address = :2200$i
|
||||
EOT
|
||||
|
||||
mkdir files-$i
|
||||
pushd files-$i >/dev/null
|
||||
../genfiles -maxexp 21 -files 4000
|
||||
../genfiles -maxexp 21 -files 400
|
||||
touch empty-$i
|
||||
../md5r > ../md5-$i
|
||||
popd >/dev/null
|
||||
done
|
||||
@@ -38,7 +43,7 @@ done
|
||||
echo "Starting..."
|
||||
for i in 1 2 3 ; do
|
||||
sleep 1
|
||||
syncthing -c conf-$i --no-gui -l :2200$i $extraopts &
|
||||
syncthing --home conf-$i $extraopts &
|
||||
done
|
||||
|
||||
cat md5-* | sort > md5-tot
|
||||
|
||||
3
main.go
3
main.go
@@ -191,6 +191,7 @@ func main() {
|
||||
// connections to other nodes.
|
||||
|
||||
infoln("Populating repository index")
|
||||
loadIndex(m)
|
||||
updateLocalModel(m)
|
||||
|
||||
// Routine to listen for incoming connections
|
||||
@@ -210,7 +211,7 @@ func main() {
|
||||
infoln("Deletes from peer nodes will be ignored")
|
||||
}
|
||||
okln("Ready to synchronize (read-write)")
|
||||
m.StartRW(opts.Delete, opts.RequestsInFlight)
|
||||
m.StartRW(opts.Delete, opts.ParallelRequests)
|
||||
} else {
|
||||
okln("Ready to synchronize (read only; no external updates accepted)")
|
||||
}
|
||||
|
||||
@@ -37,6 +37,15 @@ func Blocks(r io.Reader, blocksize int) ([]Block, error) {
|
||||
offset += int64(n)
|
||||
}
|
||||
|
||||
if len(blocks) == 0 {
|
||||
// Empty file
|
||||
blocks = append(blocks, Block{
|
||||
Offset: 0,
|
||||
Size: 0,
|
||||
Hash: []uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55},
|
||||
})
|
||||
}
|
||||
|
||||
return blocks, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ var blocksTestData = []struct {
|
||||
blocksize int
|
||||
hash []string
|
||||
}{
|
||||
{[]byte(""), 1024, []string{}},
|
||||
{[]byte(""), 1024, []string{
|
||||
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}},
|
||||
{[]byte("contents"), 1024, []string{
|
||||
"d1b2a59fbea7e20077af9f91b27e95e865061b270be03ff539ab3b73587882e8"}},
|
||||
{[]byte("contents"), 9, []string{
|
||||
@@ -86,7 +87,7 @@ var diffTestData = []struct {
|
||||
{"contents", "cantents", 3, []Block{{0, 3, nil}}},
|
||||
{"contents", "contants", 3, []Block{{3, 3, nil}}},
|
||||
{"contents", "cantants", 3, []Block{{0, 3, nil}, {3, 3, nil}}},
|
||||
{"contents", "", 3, nil},
|
||||
{"contents", "", 3, []Block{{0, 0, nil}}},
|
||||
{"", "contents", 3, []Block{{0, 3, nil}, {3, 3, nil}, {6, 2, nil}}},
|
||||
{"con", "contents", 3, []Block{{3, 3, nil}, {6, 2, nil}}},
|
||||
{"contents", "con", 3, nil},
|
||||
|
||||
@@ -48,8 +48,8 @@ type Model struct {
|
||||
|
||||
sup suppressor
|
||||
|
||||
parallellRequests int
|
||||
limitRequestRate chan struct{}
|
||||
parallelRequests int
|
||||
limitRequestRate chan struct{}
|
||||
|
||||
imut sync.Mutex // protects Index
|
||||
}
|
||||
@@ -130,7 +130,7 @@ func (m *Model) StartRW(del bool, threads int) {
|
||||
|
||||
m.rwRunning = true
|
||||
m.delete = del
|
||||
m.parallellRequests = threads
|
||||
m.parallelRequests = threads
|
||||
|
||||
go m.cleanTempFiles()
|
||||
if del {
|
||||
@@ -491,7 +491,7 @@ func (m *Model) AddConnection(rawConn io.Closer, protoConn Connection) {
|
||||
return
|
||||
}
|
||||
|
||||
for i := 0; i < m.parallellRequests; i++ {
|
||||
for i := 0; i < m.parallelRequests; i++ {
|
||||
i := i
|
||||
go func() {
|
||||
if m.trace["pull"] {
|
||||
|
||||
@@ -34,6 +34,12 @@ var testDataExpected = map[string]File{
|
||||
Modified: 0,
|
||||
Blocks: []Block{{Offset: 0x0, Size: 0x7, Hash: []uint8{0xae, 0xc0, 0x70, 0x64, 0x5f, 0xe5, 0x3e, 0xe3, 0xb3, 0x76, 0x30, 0x59, 0x37, 0x61, 0x34, 0xf0, 0x58, 0xcc, 0x33, 0x72, 0x47, 0xc9, 0x78, 0xad, 0xd1, 0x78, 0xb6, 0xcc, 0xdf, 0xb0, 0x1, 0x9f}}},
|
||||
},
|
||||
"empty": File{
|
||||
Name: "empty",
|
||||
Flags: 0,
|
||||
Modified: 0,
|
||||
Blocks: []Block{{Offset: 0x0, Size: 0x0, Hash: []uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}}},
|
||||
},
|
||||
"bar": File{
|
||||
Name: "bar",
|
||||
Flags: 0,
|
||||
|
||||
0
model/testdata/empty
vendored
Normal file
0
model/testdata/empty
vendored
Normal file
@@ -32,7 +32,7 @@ func (f File) Size() (bytes int) {
|
||||
}
|
||||
|
||||
func (f File) String() string {
|
||||
return fmt.Sprintf("File{Name:%q, Flags:0x%x, Modified:%d, Version:%d:, NumBlocks:%d}",
|
||||
return fmt.Sprintf("File{Name:%q, Flags:0x%x, Modified:%d, Version:%d, NumBlocks:%d}",
|
||||
f.Name, f.Flags, f.Modified, f.Version, len(f.Blocks))
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ var testdata = []struct {
|
||||
hash string
|
||||
}{
|
||||
{"bar", 10, "2f72cc11a6fcd0271ecef8c61056ee1eb1243be3805bf9a9df98f92f7636b05c"},
|
||||
{"empty", 0, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},
|
||||
{"foo", 7, "aec070645fe53ee3b3763059376134f058cc337247c978add178b6ccdfb0019f"},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user