app

package
v0.0.0-...-0174b01 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const SAVE string = "SAVE"

defines ops name for saving backup folder.

Variables

This section is empty.

Functions

func Backup

func Backup(maxWorkers int, logfile, src, dst, commit, tag string) (int, error)

Backup finalizes the initialization of an App instance and orchestrates required routines to monitor and handle changes.

func ViewLogs

func ViewLogs(logfile, date, reg string) (int, error)

ViewLogs uses logview routines to process the content of a given log file based on provided filters.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App is the structue of an app instance.

func New

func New(queueSize int, pid int, src, dst string, monitor Monitor, logger logger.Logger) *App

New configures a new App instance.

func (*App) AttributeEventHandler

func (app *App) AttributeEventHandler(path string)

AttributeEventHandler just logs folder or file attributes events.

func (*App) CloseQueue

func (app *App) CloseQueue()

CloseQueue close the channel of events.

func (*App) CreateBackupFile

func (app *App) CreateBackupFile(path string) error

CreateBackupFile creates a file into the backup folder with same name as the original file and use `.bat` as extension.

func (*App) CreateEventHandler

func (app *App) CreateEventHandler(path string)

CreateEventHandler orchestrates the processing of file creation events.

func (*App) DeleteEventHandler

func (app *App) DeleteEventHandler(path string)

DeleteEventHandler just logs folder or file delete events.

func (*App) DeleteRequestHandler

func (app *App) DeleteRequestHandler(path string)

DeleteRequestHandler orchestrates the processing of file deletion request.

func (*App) IsImmediateDelete

func (app *App) IsImmediateDelete(path string) bool

IsImmediateDelete checks wether the filename matches the required pattern to trigger immediate deletion action of that file.

func (*App) IsScheduleDelete

func (app *App) IsScheduleDelete(path string) (string, string, time.Time, bool)

IsScheduleDelete checks if a filename matches the required pattern to trigger a scheduling deletion action of that file. It matches if the name follow this pattern `delete_ISODATETIME`. The ISODATETIME should matches the RFC3339 ("2006-01-02T15:04:05Z07:00") format. If so, it returns the absolute source & backup filepaths and datetime.

func (*App) ModifyEventHandler

func (app *App) ModifyEventHandler(path string)

ModifyEventHandler orchestrates the processing of file content modification events.

func (*App) ReceiveFolderEventHandler

func (app *App) ReceiveFolderEventHandler(path string)

ReceiveFolderEventHandler handles folder added into the source folder. It configures the App watcher to immediately monitor all files inside the folder and its sub-folders. All files found are backed up immediately according to events rules.

func (*App) RenameEventHandler

func (app *App) RenameEventHandler(path string)

RenameEventHandler just logs folder or file renaming events.

func (*App) SaveAsZipFile

func (app *App) SaveAsZipFile(t time.Time) error

SaveAsZipFile orchestrates the creation of a zip archive of backup folder.

func (*App) ScheduleDeleteRequests

func (app *App) ScheduleDeleteRequests(at time.Time, paths ...string)

ScheduleDeleteRequests adds each absolute filepath and its deletion datetime to the map store.

func (*App) Stop

func (app *App) Stop()

Stop stops the app instance by closing the stop channel which all goroutines and workers listen on to exit.

func (*App) UpdateBackupFileContent

func (app *App) UpdateBackupFileContent(path string) (err error)

UpdateBackupFileContent copies the content of a given file path to its the backup file.

type Monitor

type Monitor interface {
	Start(context.Context, <-chan struct{}, events.Queue) error
	Stop() error
}

Monitor is an interface defining the behavior of any object capable to notifier on the source folder content changes.

Jump to

Keyboard shortcuts

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