mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 03:18:59 +00:00
d27463268d
* lib/fs: Add fakefs This adds a new fake filesystem type. It's described rather extensively in fakefs.go, but the main point is that it's for testing: when you want to spin up a Syncthing and have a terabyte or two of random files that can be synced somewhere, or an inifitely large filesystem to sync files into. It has pseudorandom properties such that data read from one fakefs can be written into another fakefs and read back and it will look consistent, without any of the data actually being stored. To use: <folder id="default" path="whatever" ...> <filesystemType>fake</filesystemType> This will create an empty fake filesystem. You can also specify that it should be prefilled with files: <folder id="default" path="whatever?size=2000000" ...> <filesystemType>fake</filesystemType> This will create a filesystem filled with 2TB of random data that can be scanned and synced. There are more options, see fakefs.go. Prefilled data is based on a deterministic seed, so you can index the data and restart Syncthing and the index is still correct for all the stored data.
42 lines
864 B
Go
42 lines
864 B
Go
// Copyright (C) 2016 The Syncthing Authors.
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
package fs
|
|
|
|
type FilesystemType int
|
|
|
|
const (
|
|
FilesystemTypeBasic FilesystemType = iota // default is basic
|
|
FilesystemTypeFake
|
|
)
|
|
|
|
func (t FilesystemType) String() string {
|
|
switch t {
|
|
case FilesystemTypeBasic:
|
|
return "basic"
|
|
case FilesystemTypeFake:
|
|
return "fake"
|
|
default:
|
|
return "unknown"
|
|
}
|
|
}
|
|
|
|
func (t FilesystemType) MarshalText() ([]byte, error) {
|
|
return []byte(t.String()), nil
|
|
}
|
|
|
|
func (t *FilesystemType) UnmarshalText(bs []byte) error {
|
|
switch string(bs) {
|
|
case "basic":
|
|
*t = FilesystemTypeBasic
|
|
case "fake":
|
|
*t = FilesystemTypeFake
|
|
default:
|
|
*t = FilesystemTypeBasic
|
|
}
|
|
return nil
|
|
}
|