fs

package
v0.16.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 16 Imported by: 2

README

Common access options

On top of the backend (fs) and its params, every access supports a few options.

Read-only

The read_only boolean blocks any write to the underlying file system.

{
  "user": "test",
  "pass": "test",
  "fs": "os",
  "read_only": true,
  "params": {
    "basePath": "/tmp"
  }
}

Shared

The shared boolean makes the backend instance created at the first login of the user reused by all their later sessions, instead of creating a new one for each session. This is useful for backends with an expensive setup (SFTP connection, Telegram bot...). An instance is reused only for the same user name and an identical access: another access with the same user name (other password, backend, parameters or read_only flag) gets its own instance. Shared instances are dropped when the configuration is reloaded.

{
  "user": "test",
  "pass": "test",
  "fs": "os",
  "shared": true,
  "params": {
    "basePath": "/tmp"
  }
}

Sync & Delete

The sync_and_delete option makes uploaded files written to a local temporary directory first, and then moved to the backend once they are complete (see afero-snd). The directory is optional, a system temporary directory is used when it isn't specified.

Files are copied to the backend in the background, after the client got its upload confirmation. When the session ends (or a shared instance is dropped by a reload), the pending copies finish before the backend is closed, waiting at most one minute. The system temporary directory is then removed; a directory set in the configuration is kept.

{
  "user": "test",
  "pass": "test",
  "fs": "os",
  "sync_and_delete": {
    "enable": true,
    "directory": "/tmp/snd"
  },
  "params": {
    "basePath": "/target"
  }
}

Logging

The logging option enables the logging of the FTP exchanges and/or the file accesses of this access only. The same options exist at the server level to enable them for all the accesses.

{
  "user": "test",
  "pass": "test",
  "fs": "os",
  "logging": {
    "ftp_exchanges": true,
    "file_accesses": true
  },
  "params": {
    "basePath": "/target"
  }
}

Documentation

Overview

Package fs provides all the core features related to file-system access

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFs

func LoadFs(access *confpar.Access, logger *slog.Logger) (afero.Fs, io.Closer, error)

LoadFs loads a file system from an access description.

The returned closer releases what the file system holds: the sync & delete wrapper (its goroutine and temporary directory, once its pending copies have reached the backend), then what the backend holds (an SFTP connection, a Telegram poller). It is nil when none of them holds anything. The wrappers applied on top of the backend (read-only, sync & delete) hide its Close method, so the caller must keep this closer and call it when the file system is no longer used.

Types

type UnsupportedFsError added in v0.8.0

type UnsupportedFsError struct {
	Type string
}

UnsupportedFsError is returned when the described file system is not supported

func (UnsupportedFsError) Error added in v0.8.0

func (err UnsupportedFsError) Error() string

Directories

Path Synopsis
Package afos provide an afero OS FS access layer
Package afos provide an afero OS FS access layer
Package dropbox provides a Dropbox layer
Package dropbox provides a Dropbox layer
Package fslog provides an afero FS logging package
Package fslog provides an afero FS logging package
Package gcs provides a Google Cloud Storage access layer
Package gcs provides a Google Cloud Storage access layer
Package gdrive provides a Google Drive access layer
Package gdrive provides a Google Drive access layer
Package keycloak provides a local file system access layer whose users are authenticated by Keycloak
Package keycloak provides a local file system access layer whose users are authenticated by Keycloak
Package mail provides a mail access layer
Package mail provides a mail access layer
Package s3 provides an AWS S3 access layer
Package s3 provides an AWS S3 access layer
Package sftp provides an SFTP connection layer
Package sftp provides an SFTP connection layer
Package stripprefix is a file-system abstraction layer to strip a part of the path
Package stripprefix is a file-system abstraction layer to strip a part of the path
Package telegram provides a telegram access layer
Package telegram provides a telegram access layer
Package utils provides helpers shared by the file systems
Package utils provides helpers shared by the file systems

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL