ydisk

package module
v0.0.0-...-5398986 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: GPL-3.0 Imports: 12 Imported by: 1

README

ydisk

GithubGo

ydisk is the go wrapper for yandex-disk CLI daemon.

It is used in yd-go project as back-end.

Tests organized via https://github.com/slytomcat/yandex-disk-simulator

Documentation

Overview

Package ydisk implements API for yandex-disk daemon. Logging is organized via github.com/slytomcat/llog package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type YDisk

type YDisk struct {
	Path    string      // Path to synchronized folder (obtained from yandex-disk conf. file)
	Changes chan YDvals // Output channel for detected changes in daemon status
	// contains filtered or unexported fields
}

YDisk provides methods to interact with yandex-disk (methods: Start, Stop, Output), path of synchronized catalogue (property Path) and channel for receiving yandex-disk status changes (property Changes).

func NewYDisk

func NewYDisk(conf string) (*YDisk, error)

NewYDisk creates new YDisk structure for communication with yandex-disk daemon Parameter:

conf - full path to yandex-disk daemon configuration file

Checks performed in the beginning:

  • check that yandex-disk was installed
  • check that yandex-disk was properly configured

When something not good NewYDisk returns not nil error

func (*YDisk) Close

func (yd *YDisk) Close()

Close deactivates the daemon connection: stops event handler that closes file watcher and Changes channel.

func (*YDisk) Output

func (yd *YDisk) Output() string

Output returns the output string of `yandex-disk status` command in the current user language.

func (*YDisk) Start

func (yd *YDisk) Start() error

Start runs `yandex-disk start` if daemon was not started before.

func (*YDisk) Stop

func (yd *YDisk) Stop() error

Stop runs `yandex-disk stop` if daemon was not stopped before.

type YDvals

type YDvals struct {
	Stat   string   // Current Status
	Prev   string   // Previous Status
	Total  string   // Total space available
	Used   string   // Used space
	Free   string   // Free space
	Trash  string   // Trash size
	Last   []string // Last-updated files/folders list (10 or less items)
	ChLast bool     // Indicator that Last was changed
	Err    string   // Error status message
	ErrP   string   // Error path
	Prog   string   // Synchronization progress (when in busy status)
}

YDvals - Daemon Status structure

Jump to

Keyboard shortcuts

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