storage

package
v0.22.9 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 115 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CachedRemoteStorageList []StorageInfo
View Source
var StorageRoutesList []StorageRoutes

Functions

func API_RClone_ConfigCreate added in v0.21.0

func API_RClone_ConfigCreate(w http.ResponseWriter, req *http.Request)

API_RClone_ConfigCreate godoc @Summary Create a new RClone remote @Tags RClone @Accept json @Produce json @Param body body object true "Remote config with name, type, and parameters" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /rclone/config/create [post]

func API_RClone_ConfigDelete added in v0.21.0

func API_RClone_ConfigDelete(w http.ResponseWriter, req *http.Request)

API_RClone_ConfigDelete godoc @Summary Delete an RClone remote @Tags RClone @Accept json @Produce json @Param body body object true "Object with name of remote to delete" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Router /rclone/config/delete [delete]

func API_RClone_ConfigDump added in v0.21.0

func API_RClone_ConfigDump(w http.ResponseWriter, req *http.Request)

API_RClone_ConfigDump godoc @Summary Dump the full RClone configuration @Tags RClone @Produce json @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Router /rclone/config/dump [get]

func API_RClone_ConfigSave added in v0.21.0

func API_RClone_ConfigSave(w http.ResponseWriter, req *http.Request)

API_RClone_ConfigSave godoc @Summary Save the RClone configuration @Tags RClone @Produce json @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Router /rclone/config/save [post]

func API_RClone_ConfigUpdate added in v0.21.0

func API_RClone_ConfigUpdate(w http.ResponseWriter, req *http.Request)

API_RClone_ConfigUpdate godoc @Summary Update an existing RClone remote @Tags RClone @Accept json @Produce json @Param body body object true "Remote update with name and parameters" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /rclone/config/update [put]

func API_RClone_CoreStats added in v0.21.0

func API_RClone_CoreStats(w http.ResponseWriter, req *http.Request)

API_RClone_CoreStats godoc @Summary Get global RClone transfer stats @Tags RClone @Produce json @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /rclone/core/stats [get]

func API_RClone_ListRemotes added in v0.22.0

func API_RClone_ListRemotes(w http.ResponseWriter, req *http.Request)

API_RClone_ListRemotes godoc @Summary List RClone remotes (name and type only, no credentials) @Tags RClone @Produce json @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Router /rclone/config/listremotes [get]

func API_RClone_OperationsAbout added in v0.21.0

func API_RClone_OperationsAbout(w http.ResponseWriter, req *http.Request)

API_RClone_OperationsAbout godoc @Summary Get storage usage info for a remote (total, used, free) @Tags RClone @Accept json @Produce json @Param body body object true "Object with fs field specifying the remote" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Failure 501 {object} utils.HTTPErrorResult @Router /rclone/operations/about [post]

func API_RClone_VfsStats added in v0.21.0

func API_RClone_VfsStats(w http.ResponseWriter, req *http.Request)

API_RClone_VfsStats godoc @Summary Get VFS stats for a mounted remote @Tags RClone @Accept json @Produce json @Param body body object true "Object with fs field specifying the remote" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Router /rclone/vfs/stats [post]

func API_Rclone_remountAll added in v0.17.0

func API_Rclone_remountAll(w http.ResponseWriter, req *http.Request)

API_Rclone_remountAll godoc @Summary Restart all RClone remote storage mounts @Tags Storage @Produce json @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Router /api/rclone-restart [get]

func AddDeviceToRaid added in v0.17.0

func AddDeviceToRaid(name string, device string) error

AddDeviceToRaid adds a new device to an existing RAID array

func CreateFolderRoute added in v0.18.0

func CreateFolderRoute(w http.ResponseWriter, req *http.Request)

CreateFolderRoute godoc @Summary Create a new folder @Tags Storage @Produce json @Param storage query string false "Storage name" @Param path query string false "Parent directory path" @Param folder query string true "Folder name to create" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/new-dir [post]

func CreateGPTTable added in v0.17.0

func CreateGPTTable(diskPath string) (io.Reader, error)

func CreateRaidArray added in v0.17.0

func CreateRaidArray(config RaidConfig) error

CreateRaidArray creates a new RAID array using mdadm

func CreateSinglePartition

func CreateSinglePartition(diskPath string) (io.Reader, error)

func CreateSnapRAID

func CreateSnapRAID(raidOptions utils.SnapRAIDConfig, editRaid string) error

Create a SnapRAID configuration

func DeleteRaidArray added in v0.17.0

func DeleteRaidArray(name string) error

DeleteRaidArray removes a RAID array

func DeleteSnapRAID

func DeleteSnapRAID(name string) error

func FormatDisk

func FormatDisk(diskPath string, filesystemType string) (io.Reader, error)

func FormatDiskRoute

func FormatDiskRoute(w http.ResponseWriter, req *http.Request)

FormatDiskRoute godoc @Summary Format a disk or partition @Description Formats the specified disk with the given filesystem format. Requires password confirmation. Streams progress output. @Tags Storage @Accept json @Produce plain @Param body body FormatDiskJSON true "Format disk request" @Security BearerAuth @Success 200 {string} string "Streamed text output ending with [OPERATION SUCCEEDED]" @Failure 400 {object} utils.HTTPErrorResult @Failure 401 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/disks/format [post]

func GetDiskUsage

func GetDiskUsage(path string) (perc uint64, err error)

func GetRaidInfo added in v0.17.0

func GetRaidInfo() ([]map[string]interface{}, error)

GetRaidInfo returns detailed information about all RAID arrays

func GetRaidStatus added in v0.17.0

func GetRaidStatus(name string) (map[string]interface{}, error)

GetRaidStatus returns the status of a specific RAID array

func InitRemoteStorage added in v0.17.0

func InitRemoteStorage()

func InitSnapRAIDConfig

func InitSnapRAIDConfig()

func IsDiskMounted

func IsDiskMounted(diskPath string) (bool, error)

check if disk is mounted

func ListDirectoryRoute added in v0.17.0

func ListDirectoryRoute(w http.ResponseWriter, req *http.Request)

ListDirectoryRoute godoc @Summary List the contents of a directory @Tags Storage @Produce json @Param storage query string false "Storage name (default: local)" @Param path query string false "Directory path (default: /)" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/list-dir [get]

func ListDisksRoute

func ListDisksRoute(w http.ResponseWriter, req *http.Request)

ListDisksRoute godoc @Summary List all disks @Tags Storage @Produce json @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/disks [get]

func ListMountsRoute

func ListMountsRoute(w http.ResponseWriter, req *http.Request)

ListMountsRoute godoc @Summary List all mounted filesystems @Tags Storage @Produce json @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/mounts [get]

func ListSmartDef

func ListSmartDef(w http.ResponseWriter, req *http.Request)

ListSmartDef godoc @Summary Get SMART attribute definitions for ATA and NVMe drives @Tags Storage @Produce json @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Router /api/smart-def [get]

func MergeRoute

func MergeRoute(w http.ResponseWriter, req *http.Request)

MergeRoute godoc @Summary Merge multiple filesystems using MergerFS @Tags Storage @Accept json @Produce json @Param body body MergeRequest true "Merge request" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/merge [post]

func Mount

func Mount(path, mountpoint string, permanent bool, netDisk bool, chown string) error

Mount mounts a filesystem located at 'path' to 'mountpoint'.

func MountMergerFS

func MountMergerFS(paths []string, mountpoint string, opts string, permanent bool, chown string) error

Mount mounts a filesystem located at 'path' to 'mountpoint'.

func MountRoute

func MountRoute(w http.ResponseWriter, req *http.Request)

MountRoute godoc @Summary Mount a filesystem @Tags Storage @Accept json @Produce json @Param body body MountRequest true "Mount request" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/mount [post]

func RaidAddDeviceRoute added in v0.17.0

func RaidAddDeviceRoute(w http.ResponseWriter, req *http.Request)

func RaidCreateRoute added in v0.17.0

func RaidCreateRoute(w http.ResponseWriter, req *http.Request)

func RaidDeleteRoute added in v0.17.0

func RaidDeleteRoute(w http.ResponseWriter, req *http.Request)

func RaidListRoute added in v0.17.0

func RaidListRoute(w http.ResponseWriter, req *http.Request)

func RaidReplaceDeviceRoute added in v0.17.0

func RaidReplaceDeviceRoute(w http.ResponseWriter, req *http.Request)

func RaidResizeRoute added in v0.17.0

func RaidResizeRoute(w http.ResponseWriter, req *http.Request)

func RaidStatusRoute added in v0.17.0

func RaidStatusRoute(w http.ResponseWriter, req *http.Request)

func ReplaceDeviceInRaid added in v0.17.0

func ReplaceDeviceInRaid(name string, oldDevice string, newDevice string) error

ReplaceDeviceInRaid replaces a failed device in a RAID array

func ResizeRaidArray added in v0.17.0

func ResizeRaidArray(name string) error

ResizeRaidArray resizes a RAID array to use all available space

func RunRClone added in v0.17.0

func RunRClone(args []string)

RunRClone runs rclone with the given arguments (CLI passthrough)

func RunSnapRAIDFix

func RunSnapRAIDFix(raid utils.SnapRAIDConfig) error

func RunSnapRAIDScrub

func RunSnapRAIDScrub(raid utils.SnapRAIDConfig) error

func RunSnapRAIDStatus

func RunSnapRAIDStatus(raid utils.SnapRAIDConfig) (string, error)

func RunSnapRAIDSync

func RunSnapRAIDSync(raid utils.SnapRAIDConfig) error

func SNAPRaidCRUDRoute

func SNAPRaidCRUDRoute(w http.ResponseWriter, req *http.Request)

SNAPRaidCRUDRoute godoc @Summary List or create SnapRAID configurations @Tags Storage @Accept json @Produce json @Param body body utils.SnapRAIDConfig false "SnapRAID config (POST only)" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/snapraid [get] @Router /api/snapraid [post]

func SnapRAIDEditRoute

func SnapRAIDEditRoute(w http.ResponseWriter, req *http.Request)

SnapRAIDEditRoute godoc @Summary Update or delete a SnapRAID configuration by name @Tags Storage @Accept json @Produce json @Param name path string true "SnapRAID config name" @Param body body utils.SnapRAIDConfig false "Updated SnapRAID config (POST only)" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/snapraid/{name} [post] @Router /api/snapraid/{name} [delete]

func SnapRAIDRunRoute

func SnapRAIDRunRoute(w http.ResponseWriter, req *http.Request)

SnapRAIDRunRoute godoc @Summary Run a SnapRAID action (sync, scrub, fix, enable, disable) @Tags Storage @Produce json @Param name path string true "SnapRAID config name" @Param action path string true "Action to run" Enums(sync, scrub, fix, enable, disable) @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Router /api/snapraid/{name}/{action} [get]

func StopAllRCloneProcess added in v0.17.0

func StopAllRCloneProcess(forever bool)

func ToggleSnapRAID

func ToggleSnapRAID(name string, enable bool) error

func Unmount

func Unmount(mountpoint string, permanent bool) error

Unmount unmounts the filesystem at 'mountpoint'.

func UnmountRoute

func UnmountRoute(w http.ResponseWriter, req *http.Request)

UnmountRoute godoc @Summary Unmount a filesystem @Tags Storage @Accept json @Produce json @Param body body MountRequest true "Unmount request" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/unmount [post]

Types

type BlockDevice

type BlockDevice struct {
	lsblk.BlockDevice
	Children []BlockDevice `json:"children"`
	Usage    uint64        `json:"usage"`
	SMART    SMARTData     `json:"smart"` // Add SMART data field
}

func GetRecursiveDiskUsageAndSMARTInfo

func GetRecursiveDiskUsageAndSMARTInfo(devices []lsblk.BlockDevice) ([]BlockDevice, error)

Function to get recursive disk usage and SMART information

func ListDisks

func ListDisks() ([]BlockDevice, error)

type DirectoryListing added in v0.17.0

type DirectoryListing struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Size     int64  `json:"size"`
	IsDir    bool   `json:"isDir"`
	Ext      string `json:"ext"`
	Created  int64  `json:"created"`
	UID      uint32 `json:"uid"`
	GID      uint32 `json:"gid"`
	FullPath string `json:"fullPath"`
}

func ListDirectory added in v0.17.0

func ListDirectory(path string) ([]DirectoryListing, error)

type DiskInfo

type DiskInfo struct {
	Path string
	Name string
	Size uint64
	Used uint64
}

type FormatDiskJSON

type FormatDiskJSON struct {
	Disk     string `json:"disk" validate:"required"`
	Format   string `json:"format" validate:"required"`
	Password string `json:"password" validate:"required"`
}

type MergeRequest

type MergeRequest struct {
	Branches   []string `json:"branches" validate:"required"`
	MountPoint string   `json:"mountPoint" validate:"required"`
	Permanent  bool     `json:"permanent"`
	Chown      string   `json:"chown"`
	Opts       string   `json:"opts"`
}

Assuming the structure for the mount/unmount request

type MountPoint

type MountPoint struct {
	Path      string   `json:"path"`
	Permenant bool     `json:"permenant"`
	Device    string   `json:"device"`
	Type      string   `json:"type"`
	Opts      []string `json:"opts"`
}

func ListMounts

func ListMounts() ([]MountPoint, error)

ListMounts lists all the mount points on the system

type MountRequest

type MountRequest struct {
	Path       string `json:"path" validate:"required"`
	MountPoint string `json:"mountPoint" validate:"required"`
	Permanent  bool   `json:"permanent"`
	NetDisk    bool   `json:"netDisk"`
	Chown      string `json:"chown"`
}

Assuming the structure for the mount/unmount request

type RaidConfig added in v0.17.0

type RaidConfig struct {
	Name       string   `json:"name" validate:"required"`
	Level      int      `json:"level"`                       // 0, 1, 5, 6, 10
	Devices    []string `json:"devices" validate:"required"` // List of device paths
	Spares     []string `json:"spares"`                      // List of spare device paths
	Metadata   string   `json:"metadata"`                    // Metadata version (default: 1.2)
	Filesystem string   `json:"filesystem"`                  // Filesystem to use (default: ext4)
}

RaidConfig represents the configuration for creating a new RAID array

type RaidDeviceRequest added in v0.17.0

type RaidDeviceRequest struct {
	Device string `json:"device" validate:"required"`
}

type RaidReplaceDeviceRequest added in v0.17.0

type RaidReplaceDeviceRequest struct {
	OldDevice string `json:"oldDevice" validate:"required"`
	NewDevice string `json:"newDevice" validate:"required"`
}

type RcloneStatsObj added in v0.17.0

type RcloneStatsObj struct {
	Bytes  float64
	Errors float64
}

func RCloneStats added in v0.17.0

func RCloneStats() (RcloneStatsObj, error)

type RemoteStorage added in v0.17.0

type RemoteStorage struct {
	Name  string
	Chown string
}

type SMARTData

type SMARTData struct {
	smart.GenericAttributes

	AdditionalData interface{}
	Thresholds     interface{}
}

type ServeHandle added in v0.21.0

type ServeHandle interface {
	Serve() error
	Shutdown() error
}

ServeHandle is the interface that serve servers implement

type SnapRAIDStatus

type SnapRAIDStatus struct {
	utils.SnapRAIDConfig
	Status string
}

type StorageInfo added in v0.17.0

type StorageInfo struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

func ListStorage added in v0.17.0

func ListStorage() ([]StorageInfo, error)

type StorageRoutes added in v0.17.0

type StorageRoutes struct {
	Name        string
	Protocol    string
	Source      string
	Target      string
	SmartShield bool
}

Jump to

Keyboard shortcuts

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