repo
stringlengths
6
47
file_url
stringlengths
77
269
file_path
stringlengths
5
186
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-07 08:35:43
2026-01-07 08:55:24
truncated
bool
2 classes
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/encoder/encoder.go
lib/encoder/encoder.go
// Package encoder provides functionality to translate file names // for usage on restrictive storage systems. // // The restricted set of characters are mapped to a unicode equivalent version // (most to their FULLWIDTH variant) to increase compatibility with other // storage systems. // See: http://unicode-search.net...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/encoder/filename/fuzz.go
lib/encoder/filename/fuzz.go
//go:build gofuzz package filename import ( "bytes" "fmt" ) // Run like: // go-fuzz-build -o=fuzz-build.zip -func=Fuzz . && go-fuzz -minimize=5s -bin=fuzz-build.zip -workdir=testdata/corpus -procs=24 // Fuzz test the provided input. func Fuzz(data []byte) int { // First try to decode as is. // We don't care abo...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/encoder/filename/init.go
lib/encoder/filename/init.go
// Package filename provides utilities for encoder. package filename import ( "encoding/base64" "sync" "github.com/klauspost/compress/huff0" ) // encodeURL is base64 url encoding values. const encodeURL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" // decodeMap will return x = decodeMap[en...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/encoder/filename/gentable.go
lib/encoder/filename/gentable.go
//go:build ignore package main import ( "bufio" "bytes" "encoding/base64" "flag" "fmt" "math" "os" "strings" "unicode/utf8" "github.com/dop251/scsu" "github.com/klauspost/compress" "github.com/klauspost/compress/huff0" ) // execute go run gentable.go var indexFile = flag.String("index", "", "Index this ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/encoder/filename/encode.go
lib/encoder/filename/encode.go
package filename import ( "encoding/base64" "encoding/binary" "github.com/dop251/scsu" "github.com/klauspost/compress/huff0" ) // Encode will encode the string and return a base64 (url) compatible version of it. // Calling Decode with the returned string should always succeed. // It is not a requirement that the...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/encoder/filename/decode.go
lib/encoder/filename/decode.go
package filename import ( "bytes" "encoding/base64" "encoding/binary" "errors" "sync" "github.com/dop251/scsu" "github.com/klauspost/compress/huff0" ) // ErrCorrupted is returned if a provided encoded filename cannot be decoded. var ErrCorrupted = errors.New("file name corrupt") // ErrUnsupported is returned...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/encoder/filename/decode_test.go
lib/encoder/filename/decode_test.go
package filename import ( "testing" ) func TestDecode(t *testing.T) { tests := []struct { name string encoded string want string wantErr bool }{ { name: "uncompressed", // tableUncompressed encoded: "AYS5i", want: "a.b", }, { name: "uncompressed-long", // tableUncompressed ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/encoder/internal/gen/main.go
lib/encoder/internal/gen/main.go
// Package main provides utilities for encoder. package main import ( "flag" "fmt" "math/rand" "os" "slices" "strconv" "strings" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/lib/encoder" ) const ( edgeLeft = iota edgeRight ) type mapping struct { mask encoder.MultiEncoder src, dst []rune...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/caller/caller_test.go
lib/caller/caller_test.go
package caller import ( "testing" "github.com/stretchr/testify/assert" ) func TestPresent(t *testing.T) { assert.False(t, Present("NotFound")) assert.False(t, Present("TestPresent")) f := func() { assert.True(t, Present("TestPresent")) } f() } func BenchmarkPresent(b *testing.B) { for b.Loop() { _ = Pre...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/caller/caller.go
lib/caller/caller.go
// Package caller contains functions to examine the call stack. package caller import ( "runtime" "strings" ) // Present looks for functionName in the call stack and return true if found // // Note that this ignores the caller. func Present(functionName string) bool { var pcs [48]uintptr n := runtime.Callers(3, p...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/sdactivation/sdactivation_stub.go
lib/sdactivation/sdactivation_stub.go
//go:build windows || plan9 // Package sdactivation provides support for systemd socket activation, // wrapping the coreos/go-systemd package. // This wraps the underlying go-systemd binary, as it fails to build on plan9 // https://github.com/coreos/go-systemd/pull/440 package sdactivation import ( "net" ) // Liste...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/sdactivation/sdactivation_unix.go
lib/sdactivation/sdactivation_unix.go
//go:build !windows && !plan9 // Package sdactivation provides support for systemd socket activation, wrapping // the coreos/go-systemd package. // This wraps the underlying go-systemd library, as it fails to build on plan9 // https://github.com/coreos/go-systemd/pull/440 package sdactivation import ( "net" sdActi...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/mmap/mmap_unsupported.go
lib/mmap/mmap_unsupported.go
// Fallback Alloc and Free for unsupported OSes //go:build plan9 || js package mmap // Alloc allocates size bytes and returns a slice containing them. If // the allocation fails it will return with an error. This is best // used for allocations which are a multiple of the Pagesize. func Alloc(size int) ([]byte, er...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/mmap/mmap.go
lib/mmap/mmap.go
// Package mmap provides memory mapped related utilities. package mmap import "os" // PageSize is the minimum allocation size. Allocations will use at // least this size and are likely to be multiplied up to a multiple of // this size. var PageSize = os.Getpagesize() // MustAlloc allocates size bytes and returns a ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/mmap/mmap_windows.go
lib/mmap/mmap_windows.go
// Package mmap implements a large block memory allocator using // anonymous memory maps. //go:build windows package mmap import ( "fmt" "unsafe" "golang.org/x/sys/windows" ) // Alloc allocates size bytes and returns a slice containing them. If // the allocation fails it will return with an error. This is bes...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/mmap/mmap_test.go
lib/mmap/mmap_test.go
package mmap import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) // Constants to control the benchmarking const ( maxAllocs = 16 * 1024 ) func TestAllocFree(t *testing.T) { const Size = 4096 b := MustAlloc(Size) assert.Equal(t, Size, len(b)) // check we can write to all the memory for i := ra...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/mmap/mmap_unix.go
lib/mmap/mmap_unix.go
// Package mmap implements a large block memory allocator using // anonymous memory maps. //go:build !plan9 && !windows && !js package mmap import ( "fmt" "golang.org/x/sys/unix" ) // Alloc allocates size bytes and returns a slice containing them. If // the allocation fails it will return with an error. This i...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/pacer/pacers.go
lib/pacer/pacers.go
package pacer import ( "math/rand" "time" "golang.org/x/time/rate" ) type ( // MinSleep configures the minimum sleep time of a Calculator MinSleep time.Duration // MaxSleep configures the maximum sleep time of a Calculator MaxSleep time.Duration // DecayConstant configures the decay constant time of a Calcul...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/pacer/pacer_test.go
lib/pacer/pacer_test.go
package pacer import ( "errors" "fmt" "strings" "sync" "testing" "time" "github.com/stretchr/testify/assert" ) func TestNew(t *testing.T) { const expectedRetries = 7 const expectedConnections = 9 p := New(RetriesOption(expectedRetries), MaxConnectionsOption(expectedConnections)) if d, ok := p.calculator.(...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/pacer/pacer.go
lib/pacer/pacer.go
// Package pacer makes pacing and retrying API calls easy package pacer import ( "errors" "fmt" "sync" "time" "github.com/rclone/rclone/lib/caller" liberrors "github.com/rclone/rclone/lib/errors" ) // State represents the public Pacer state that will be passed to the // configured Calculator type State struct ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/pacer/tokens_test.go
lib/pacer/tokens_test.go
package pacer import ( "testing" "github.com/stretchr/testify/assert" ) func TestTokenDispenser(t *testing.T) { td := NewTokenDispenser(5) assert.Equal(t, 5, len(td.tokens)) td.Get() assert.Equal(t, 4, len(td.tokens)) td.Put() assert.Equal(t, 5, len(td.tokens)) }
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/pacer/tokens.go
lib/pacer/tokens.go
// Tokens for controlling concurrency package pacer // TokenDispenser is for controlling concurrency type TokenDispenser struct { tokens chan struct{} } // NewTokenDispenser makes a pool of n tokens func NewTokenDispenser(n int) *TokenDispenser { td := &TokenDispenser{ tokens: make(chan struct{}, n), } // Fill...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/diskusage/diskusage_unix.go
lib/diskusage/diskusage_unix.go
//go:build aix || android || darwin || dragonfly || freebsd || ios || linux package diskusage import ( "golang.org/x/sys/unix" ) // New returns the disk status for dir. // // May return Unsupported error if it doesn't work on this platform. func New(dir string) (info Info, err error) { var statfs unix.Statfs_t er...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/diskusage/diskusage_netbsd.go
lib/diskusage/diskusage_netbsd.go
//go:build netbsd package diskusage import ( "golang.org/x/sys/unix" ) // New returns the disk status for dir. // // May return Unsupported error if it doesn't work on this platform. func New(dir string) (info Info, err error) { var statfs unix.Statvfs_t err = unix.Statvfs(dir, &statfs) if err != nil { return ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/diskusage/diskusage_openbsd.go
lib/diskusage/diskusage_openbsd.go
//go:build openbsd package diskusage import ( "golang.org/x/sys/unix" ) // New returns the disk status for dir. // // May return Unsupported error if it doesn't work on this platform. func New(dir string) (info Info, err error) { var statfs unix.Statfs_t err = unix.Statfs(dir, &statfs) if err != nil { return i...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/diskusage/diskusage_windows.go
lib/diskusage/diskusage_windows.go
//go:build windows package diskusage import ( "golang.org/x/sys/windows" ) // New returns the disk status for dir. // // May return Unsupported error if it doesn't work on this platform. func New(dir string) (info Info, err error) { dir16 := windows.StringToUTF16Ptr(dir) err = windows.GetDiskFreeSpaceEx(dir16, &i...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/diskusage/diskusage_unsupported.go
lib/diskusage/diskusage_unsupported.go
//go:build illumos || js || plan9 || solaris package diskusage // New returns the disk status for dir. // // May return Unsupported error if it doesn't work on this platform. func New(dir string) (info Info, err error) { return info, ErrUnsupported }
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/diskusage/diskusage_test.go
lib/diskusage/diskusage_test.go
package diskusage import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestNew(t *testing.T) { info, err := New(".") if err == ErrUnsupported { t.Skip(err) } require.NoError(t, err) t.Logf("Free %16d", info.Free) t.Logf("Available %16d", info.Available)...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/diskusage/diskusage.go
lib/diskusage/diskusage.go
// Package diskusage provides a cross platform version of the statfs // system call to read disk space usage. package diskusage import "errors" // Info is returned from New showing details about the disk. type Info struct { Free uint64 // total free bytes Available uint64 // free bytes available to the current...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/terminal/terminal_normal.go
lib/terminal/terminal_normal.go
//go:build !js package terminal import ( "fmt" "os" "golang.org/x/term" ) // GetSize reads the dimensions of the current terminal or returns a // sensible default func GetSize() (w, h int) { w, h, err := term.GetSize(int(os.Stdout.Fd())) if err != nil { w, h = 80, 25 } return w, h } // IsTerminal returns ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/terminal/terminal.go
lib/terminal/terminal.go
// Package terminal provides VT100 terminal codes and a windows // implementation of that. package terminal import ( "context" "io" "os" "runtime" "sync" colorable "github.com/mattn/go-colorable" "github.com/rclone/rclone/fs" ) // VT100 codes const ( EraseLine = "\x1b[2K" MoveToStartOfLine = "\x1b[1...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/terminal/hidden_windows.go
lib/terminal/hidden_windows.go
//go:build windows package terminal import ( "golang.org/x/sys/windows" ) // HideConsole hides the console window and activates another window func HideConsole() { getConsoleWindow := windows.NewLazySystemDLL("kernel32.dll").NewProc("GetConsoleWindow") showWindow := windows.NewLazySystemDLL("user32.dll").NewProc(...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/terminal/hidden_other.go
lib/terminal/hidden_other.go
//go:build !windows package terminal // HideConsole is only supported on windows func HideConsole() { }
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/terminal/terminal_unsupported.go
lib/terminal/terminal_unsupported.go
//go:build js package terminal import "errors" // GetSize reads the dimensions of the current terminal or returns a // sensible default func GetSize() (w, h int) { return 80, 25 } // IsTerminal returns whether the fd passed in is a terminal or not func IsTerminal(fd int) bool { return false } // ReadPassword rea...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/exitcode/exitcode.go
lib/exitcode/exitcode.go
// Package exitcode exports rclone's exit status numbers. package exitcode const ( // Success is returned when rclone finished without error. Success = iota // UncategorizedError is returned for any error not categorised otherwise. UncategorizedError // UsageError is returned when there was a syntax or usage erro...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/transform/gen_help.go
lib/transform/gen_help.go
// Create the help text for transform // // Run with go generate (defined in transform.go) // //go:build none package main import ( "context" "fmt" "os" "strings" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/lib/encoder" "github.com/rclone/rclone/lib/transform" ) type commands struct { command ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/transform/transform_test.go
lib/transform/transform_test.go
package transform import ( "context" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) // sync tests are in fs/sync/sync_transform_test.go to avoid import cycle issues func newOptions(s ...string) (context.Context, error) { ctx := context.Background() err := SetOpt...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/transform/transform.go
lib/transform/transform.go
// Package transform holds functions for path name transformations // //go:generate go run gen_help.go transform.md package transform import ( "bytes" "context" _ "embed" "encoding/base64" "errors" "fmt" "mime" "net/url" "os/exec" "path" "regexp" "strconv" "strings" "time" "unicode/utf8" "github.com/r...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/transform/options.go
lib/transform/options.go
package transform import ( "context" "errors" "slices" "strings" "sync" "github.com/rclone/rclone/fs" ) type transform struct { key Algo // for example, "prefix" value string // for example, "some_prefix_" tag tag // file, dir, or all } // tag controls which part of the file path is affected (file...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/transform/cmap.go
lib/transform/cmap.go
package transform import ( "fmt" "strings" "sync" "github.com/rclone/rclone/fs" "golang.org/x/text/encoding/charmap" ) var ( cmaps = map[int]*charmap.Charmap{} lock sync.Mutex ) // CharmapChoices is an enum of the character map choices. type CharmapChoices = fs.Enum[cmapChoices] type cmapChoices struct{} ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/structs/structs_test.go
lib/structs/structs_test.go
package structs import ( "fmt" "net/http" "testing" "github.com/stretchr/testify/assert" ) // returns the "%p" representation of the thing passed in func ptr(p any) string { return fmt.Sprintf("%p", p) } func TestSetDefaults(t *testing.T) { old := http.DefaultTransport.(*http.Transport) newT := new(http.Tran...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/structs/structs.go
lib/structs/structs.go
// Package structs is for manipulating structures with reflection package structs import ( "reflect" ) // SetFrom sets the public members of a from b // // a and b should be pointers to structs // // a can be a different type from b // // Only the Fields which have the same name and assignable type on a // and b wil...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/kv/types.go
lib/kv/types.go
package kv import ( "context" "errors" ) // package errors var ( ErrEmpty = errors.New("database empty") ErrInactive = errors.New("database stopped") ErrUnsupported = errors.New("unsupported on this OS") ) // Op represents a database operation type Op interface { Do(context.Context, Bucket) error } /...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/kv/unsupported.go
lib/kv/unsupported.go
//go:build plan9 || js // Package kv provides key/value database. package kv import ( "context" "github.com/rclone/rclone/fs" ) // DB represents a key-value database type DB struct{} // Supported returns true on supported OSes func Supported() bool { return false } // Start a key-value database func Start(ctx c...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/kv/internal_test.go
lib/kv/internal_test.go
//go:build !plan9 && !js package kv import ( "context" "fmt" "sync" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestKvConcurrency(t *testing.T) { require.Equal(t, 0, len(dbMap), "no databases can be started initially") const threadNum = 5 var wg sync.WaitGro...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/kv/bolt.go
lib/kv/bolt.go
//go:build !plan9 && !js // Package kv provides key/value database. package kv import ( "context" "fmt" "os" "path/filepath" "strings" "sync" "time" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/config" "github.com/rclone/rclone/lib/encoder" "go.etcd.io/bbolt" ) const ( initTime = 24 * ti...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/gzip_test.go
lib/readers/gzip_test.go
package readers import ( "bytes" "compress/gzip" "io" "testing" "github.com/rclone/rclone/lib/random" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) type checkClose struct { io.Reader closed bool } func (cc *checkClose) Close() error { cc.closed = true return nil } func Tes...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/pattern_reader_test.go
lib/readers/pattern_reader_test.go
package readers import ( "io" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestPatternReader(t *testing.T) { b2 := make([]byte, 1) r := NewPatternReader(0) b, err := io.ReadAll(r) require.NoError(t, err) assert.Equal(t, []byte{}, b) n, err := r.Read(b2) requ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/gzip.go
lib/readers/gzip.go
package readers import ( "compress/gzip" "io" ) // gzipReader wraps a *gzip.Reader so it closes the underlying stream // which the gzip library doesn't. type gzipReader struct { *gzip.Reader in io.ReadCloser } // NewGzipReader returns an io.ReadCloser which will read the stream // and close it when Close is call...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/error.go
lib/readers/error.go
package readers // ErrorReader wraps an error to return on Read type ErrorReader struct { Err error } // Read always returns the error func (er ErrorReader) Read(p []byte) (n int, err error) { return 0, er.Err }
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/readfill.go
lib/readers/readfill.go
package readers import "io" // ReadFill reads as much data from r into buf as it can // // It reads until the buffer is full or r.Read returned an error. // // This is io.ReadFull but when you just want as much data as // possible, not an exact size of block. func ReadFill(r io.Reader, buf []byte) (n int, err error) ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/error_test.go
lib/readers/error_test.go
package readers import ( "errors" "testing" "github.com/stretchr/testify/assert" ) func TestErrorReader(t *testing.T) { errRead := errors.New("boom") r := ErrorReader{errRead} buf := make([]byte, 16) n, err := r.Read(buf) assert.Equal(t, errRead, err) assert.Equal(t, 0, n) }
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/context_test.go
lib/readers/context_test.go
package readers import ( "context" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestContextReader(t *testing.T) { r := NewPatternReader(100) ctx, cancel := context.WithCancel(context.Background()) cr := NewContextReader(ctx, r) var buf = make([]byte, 3) n, er...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/fakeseeker_test.go
lib/readers/fakeseeker_test.go
package readers import ( "bytes" "io" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) // Check interface var _ io.ReadSeeker = &FakeSeeker{} func TestFakeSeeker(t *testing.T) { // Test that passing in an io.ReadSeeker just passes it through bufReader := bytes.NewReader(...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/noclose.go
lib/readers/noclose.go
package readers import "io" // noClose is used to wrap an io.Reader to stop it being upgraded type noClose struct { in io.Reader } // Read implements io.Closer by passing it straight on func (nc noClose) Read(p []byte) (n int, err error) { return nc.in.Read(p) } // NoCloser makes sure that the io.Reader passed in...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/noseeker.go
lib/readers/noseeker.go
package readers import ( "errors" "io" ) var ( errCantSeek = errors.New("can't Seek") ) // NoSeeker adapts an io.Reader into an io.ReadSeeker. // // However if Seek() is called it will return an error. type NoSeeker struct { io.Reader } // Seek the stream - returns an error func (r NoSeeker) Seek(offset int64, ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/fakeseeker.go
lib/readers/fakeseeker.go
package readers import ( "errors" "fmt" "io" ) // FakeSeeker adapts an io.Seeker into an io.ReadSeeker type FakeSeeker struct { in io.Reader readErr error length int64 offset int64 read bool } // NewFakeSeeker creates a fake io.ReadSeeker from an io.Reader // // This can be seeked before reading to...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/repeatable_test.go
lib/readers/repeatable_test.go
package readers import ( "bytes" "io" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestRepeatableReader(t *testing.T) { var dst []byte var n int var pos int64 var err error b := []byte("Testbuffer") buf := bytes.NewBuffer(b) r := NewRepeatableReader(buf) ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/noseeker_test.go
lib/readers/noseeker_test.go
package readers import ( "bytes" "io" "testing" "github.com/stretchr/testify/assert" ) func TestNoSeeker(t *testing.T) { r := bytes.NewBufferString("hello") rs := NoSeeker{Reader: r} // Check read b := make([]byte, 4) n, err := rs.Read(b) assert.NoError(t, err) assert.Equal(t, 4, n) assert.Equal(t, []by...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/limited.go
lib/readers/limited.go
package readers import ( "io" "github.com/rclone/rclone/fs" ) // LimitedReadCloser adds io.Closer to io.LimitedReader. Create one with NewLimitedReadCloser type LimitedReadCloser struct { *io.LimitedReader io.Closer } // Close closes the underlying io.Closer. The error, if any, will be ignored if data is read ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/noclose_test.go
lib/readers/noclose_test.go
package readers import ( "errors" "io" "testing" "github.com/stretchr/testify/assert" ) var errRead = errors.New("read error") type readOnly struct{} func (readOnly) Read(p []byte) (n int, err error) { return 0, io.EOF } type readClose struct{} func (readClose) Read(p []byte) (n int, err error) { return 0,...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/context.go
lib/readers/context.go
// Package readers provides io.Reader related utilities. package readers import ( "context" "io" ) // NewContextReader creates a reader, that returns any errors that ctx gives func NewContextReader(ctx context.Context, r io.Reader) io.Reader { return &contextReader{ ctx: ctx, r: r, } } type contextReader s...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/readfill_test.go
lib/readers/readfill_test.go
package readers import ( "io" "testing" "github.com/stretchr/testify/assert" ) type byteReader struct { c byte } func (br *byteReader) Read(p []byte) (n int, err error) { if br.c == 0 { err = io.EOF } else if len(p) >= 1 { p[0] = br.c n = 1 br.c-- } return } func TestReadFill(t *testing.T) { buf :...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/repeatable.go
lib/readers/repeatable.go
package readers import ( "errors" "io" "sync" ) // A RepeatableReader implements the io.ReadSeeker it allow to seek cached data // back and forth within the reader but will only read data from the internal Reader as necessary // and will play nicely with the Account and io.LimitedReader to reflect current speed ty...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/pattern_reader.go
lib/readers/pattern_reader.go
package readers import ( "errors" "io" ) // This is the smallest prime less than 256 // // Using a prime here means we are less likely to hit repeating patterns const patternReaderModulo = 251 // NewPatternReader creates a reader, that returns a deterministic byte pattern. // After length bytes are read func NewPa...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/readers/counting_reader.go
lib/readers/counting_reader.go
package readers import "io" // NewCountingReader returns a CountingReader, which will read from the given // reader while keeping track of how many bytes were read. func NewCountingReader(in io.Reader) *CountingReader { return &CountingReader{in: in} } // CountingReader holds a reader and a read count of how many b...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/bucket/bucket.go
lib/bucket/bucket.go
// Package bucket is contains utilities for managing bucket-based backends package bucket import ( "errors" "strings" "sync" ) var ( // ErrAlreadyDeleted is returned when an already deleted // bucket is passed to Remove ErrAlreadyDeleted = errors.New("bucket already deleted") ) // Split takes an absolute path ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/bucket/bucket_test.go
lib/bucket/bucket_test.go
package bucket import ( "errors" "fmt" "testing" "github.com/stretchr/testify/assert" ) func TestSplit(t *testing.T) { for _, test := range []struct { in string wantBucket string wantPath string }{ {in: "", wantBucket: "", wantPath: ""}, {in: "bucket", wantBucket: "bucket", wantPath: ""}, ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/ranges/ranges.go
lib/ranges/ranges.go
// Package ranges provides the Ranges type for keeping track of byte // ranges which may or may not be present in an object. package ranges import ( "sort" ) // Range describes a single byte range type Range struct { Pos int64 Size int64 } // End returns the end of the Range func (r Range) End() int64 { return ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/ranges/ranges_test.go
lib/ranges/ranges_test.go
package ranges import ( "fmt" "math/rand" "slices" "testing" "github.com/stretchr/testify/assert" ) func TestRangeEnd(t *testing.T) { assert.Equal(t, int64(3), Range{Pos: 1, Size: 2}.End()) } func TestRangeIsEmpty(t *testing.T) { assert.Equal(t, false, Range{Pos: 1, Size: 2}.IsEmpty()) assert.Equal(t, true,...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/daemonize/daemon_unix.go
lib/daemonize/daemon_unix.go
//go:build unix && !aix // Package daemonize provides daemonization interface for Unix platforms. package daemonize import ( "fmt" "os" "strings" "syscall" "github.com/rclone/rclone/fs" "golang.org/x/sys/unix" ) // StartDaemon runs background twin of current process. // It executes separate parts of code in c...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/daemonize/daemon_other.go
lib/daemonize/daemon_other.go
//go:build !unix || aix // Package daemonize provides daemonization stub for non-Unix platforms. package daemonize import ( "fmt" "os" "runtime" ) var errNotSupported = fmt.Errorf("daemon mode is not supported on the %s platform", runtime.GOOS) // StartDaemon runs background twin of current process. func StartDa...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/israce/israce.go
lib/israce/israce.go
//go:build race // Package israce reports if the Go race detector is enabled. // // From https://stackoverflow.com/questions/44944959/how-can-i-check-if-the-race-detector-is-enabled-at-runtime package israce // Enabled reports if the race detector is enabled. const Enabled = true
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/israce/norace.go
lib/israce/norace.go
//go:build !race // Package israce reports if the Go race detector is enabled. // // From https://stackoverflow.com/questions/44944959/how-can-i-check-if-the-race-detector-is-enabled-at-runtime package israce // Enabled reports if the race detector is enabled. const Enabled = false
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/atexit/atexit_test.go
lib/atexit/atexit_test.go
package atexit import ( "os" "runtime" "testing" "github.com/rclone/rclone/lib/exitcode" "github.com/stretchr/testify/assert" ) type fakeSignal struct{} func (*fakeSignal) String() string { return "fake" } func (*fakeSignal) Signal() { } var _ os.Signal = (*fakeSignal)(nil) func TestExitCode(t *testing.T) ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/atexit/atexit.go
lib/atexit/atexit.go
// Package atexit provides handling for functions you want called when // the program exits unexpectedly due to a signal. // // You should also make sure you call Run in the normal exit path. package atexit import ( "os" "os/signal" "sync" "sync/atomic" "github.com/rclone/rclone/fs" ) var ( fns = make...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/atexit/atexit_other.go
lib/atexit/atexit_other.go
//go:build windows || plan9 package atexit import ( "os" "github.com/rclone/rclone/lib/exitcode" ) var exitSignals = []os.Signal{os.Interrupt} func exitCode(_ os.Signal) int { return exitcode.UncategorizedError }
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/atexit/atexit_unix.go
lib/atexit/atexit_unix.go
//go:build !windows && !plan9 package atexit import ( "os" "syscall" "github.com/rclone/rclone/lib/exitcode" ) var exitSignals = []os.Signal{syscall.SIGINT, syscall.SIGTERM} // Not syscall.SIGQUIT as we want the default behaviour // exitCode calculates the exit code for the given signal. Many Unix programs // e...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/multipart/multipart.go
lib/multipart/multipart.go
// Package multipart implements generic multipart uploading. package multipart import ( "context" "fmt" "io" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/accounting" "github.com/rclone/rclone/lib/atexit" "github.com/rclone/rclone/lib/pacer" "github.com/rclone/rclone/lib/pool" "golang.org/x/sync...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/rest/rest.go
lib/rest/rest.go
// Package rest implements a simple REST wrapper // // All methods are safe for concurrent calling. package rest import ( "bytes" "context" "encoding/json" "encoding/xml" "errors" "fmt" "io" "maps" "mime/multipart" "net/http" "net/url" "sync" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/lib/r...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/rest/url.go
lib/rest/url.go
package rest import ( "fmt" "net/url" "strings" ) // URLJoin joins a URL and a path returning a new URL // // path should be URL escaped func URLJoin(base *url.URL, path string) (*url.URL, error) { rel, err := url.Parse(path) if err != nil { return nil, fmt.Errorf("error parsing %q as URL: %w", path, err) } ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/rest/headers_test.go
lib/rest/headers_test.go
package rest import ( "net/http" "testing" "github.com/stretchr/testify/assert" ) func TestParseSizeFromHeaders(t *testing.T) { testCases := []struct { ContentLength, ContentRange string Size int64 }{{ "", "", -1, }, { "42", "", 42, }, { "42", "invalid", -1, }, { "", "bytes...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/rest/url_test.go
lib/rest/url_test.go
package rest import ( "fmt" "net/url" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestURLJoin(t *testing.T) { for i, test := range []struct { base string path string wantOK bool want string }{ {"http://example.com/", "potato", true, "http://examp...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/rest/headers.go
lib/rest/headers.go
package rest import ( "net/http" "strconv" "strings" ) // ParseSizeFromHeaders parses HTTP response headers to get the full file size. // Returns -1 if the headers did not exist or were invalid. func ParseSizeFromHeaders(headers http.Header) (size int64) { size = -1 var contentLength = headers.Get("Content-Leng...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/random/random_test.go
lib/random/random_test.go
package random import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestStringLength(t *testing.T) { for i := range 100 { s := String(i) assert.Equal(t, i, len(s)) } } func TestStringDuplicates(t *testing.T) { seen := map[string]bool{} for range 100 { s :...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/random/random.go
lib/random/random.go
// Package random holds a few functions for working with random numbers package random import ( cryptorand "crypto/rand" "encoding/base64" "fmt" "io" ) // StringFn create a random string for test purposes using the random // number generator function passed in. // // Do not use these for passwords. func StringFn(...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/batcher/batcher_test.go
lib/batcher/batcher_test.go
package batcher import ( "context" "errors" "fmt" "sync" "sync/atomic" "testing" "time" "github.com/rclone/rclone/fs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) type ( Result string Item string ) func TestBatcherNew(t *testing.T) { ctx := context.Background() ci := ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/batcher/options.go
lib/batcher/options.go
package batcher import ( "fmt" "time" "github.com/rclone/rclone/fs" ) // FsOptions returns the batch mode fs.Options func (opt *Options) FsOptions(extra string) []fs.Option { return []fs.Option{{ Name: "batch_mode", Help: fmt.Sprintf(`Upload file batching sync|async|off. This sets the batch mode used by rcl...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/batcher/batcher.go
lib/batcher/batcher.go
// Package batcher implements a generic batcher. // // It uses two types: // // Item - the thing to be batched // Result - the result from the batching // // And one function of type CommitBatchFn which is called to do the actual batching. package batcher import ( "context" "errors" "fmt" "sync" "time" "github....
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/debug/common.go
lib/debug/common.go
// Package debug contains functions for dealing with runtime/debug functions across go versions package debug import ( "runtime/debug" ) // SetGCPercent calls the runtime/debug.SetGCPercent function to set the garbage // collection percentage. func SetGCPercent(percent int) int { return debug.SetGCPercent(percent) ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/dircache/dircache.go
lib/dircache/dircache.go
// Package dircache provides a simple cache for caching directory ID // to path lookups and the inverse. package dircache // _methods are called without the lock import ( "bytes" "context" "errors" "fmt" "path" "strings" "sync" "github.com/rclone/rclone/fs" ) // DirCache caches paths to directory IDs and vi...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/http/middleware.go
lib/http/middleware.go
package http import ( "context" "encoding/base64" "fmt" "net/http" "regexp" "strings" "sync" goauth "github.com/abbot/go-http-auth" "github.com/rclone/rclone/fs" ) // parseAuthorization parses the Authorization header into user, pass // it returns a boolean as to whether the parse was successful func parseA...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/http/middleware_test.go
lib/http/middleware_test.go
package http import ( "context" "crypto/tls" "errors" "fmt" "net/http" "strings" "testing" "github.com/stretchr/testify/require" ) func TestMiddlewareAuth(t *testing.T) { servers := []struct { name string expectedUser string remoteUser string http Config auth AuthConfig ...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/http/server_test.go
lib/http/server_test.go
package http import ( "context" "crypto/tls" "fmt" "io" "net" "net/http" "os" "path/filepath" "strings" "testing" "github.com/stretchr/testify/require" ) func testEmptyHandler() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) } func testEchoHandler(data []byte) ht...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/http/server.go
lib/http/server.go
// Package http provides a registration interface for http services package http import ( "bytes" "context" "crypto/tls" "crypto/x509" "errors" "fmt" "html/template" "net" "net/http" "os" "path/filepath" "strings" "sync" "time" "github.com/go-chi/chi/v5" "github.com/rclone/rclone/fs" "github.com/rclo...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/http/auth.go
lib/http/auth.go
package http import ( "bytes" "fmt" "html/template" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/config/flags" "github.com/spf13/pflag" ) // AuthHelp returns text describing the http authentication to add to the command help. func AuthHelp(prefix string) string { help := `#### Authentication By...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/http/context.go
lib/http/context.go
package http import ( "context" "net" "net/http" ) type ctxKey int const ( ctxKeyAuth ctxKey = iota ctxKeyPublicURL ctxKeyUnixSock ctxKeyUser ) // NewBaseContext initializes the context for all requests, adding info for use in middleware and handlers func NewBaseContext(ctx context.Context, url string) func(...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/http/template_test.go
lib/http/template_test.go
package http import ( "strings" "testing" ) func TestHelpPrefixTemplate(t *testing.T) { // This test assumes template variables are placed correctly. const testPrefix = "template-help-test" helpMessage := TemplateHelp(testPrefix) if !strings.Contains(helpMessage, testPrefix) { t.Fatal("flag prefix not found")...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/http/template.go
lib/http/template.go
package http import ( "bytes" "embed" "fmt" "html/template" "os" "strings" "time" "github.com/spf13/pflag" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/config/flags" ) // TemplateHelp returns a string that describes how to use a custom template func TemplateHelp(prefix string) string { help...
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false
rclone/rclone
https://github.com/rclone/rclone/blob/5f4e4b1a200708f5f36999a9d289823b742e4fd3/lib/http/auth_test.go
lib/http/auth_test.go
package http import ( "strings" "testing" ) func TestHelpPrefixAuth(t *testing.T) { // This test assumes template variables are placed correctly. const testPrefix = "server-help-test" helpMessage := AuthHelp(testPrefix) if !strings.Contains(helpMessage, testPrefix) { t.Fatal("flag prefix not found") } }
go
MIT
5f4e4b1a200708f5f36999a9d289823b742e4fd3
2026-01-07T08:35:43.525317Z
false