files

package
v0.0.0-...-46646b9 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChunkInfo

type ChunkInfo struct {
	Hash         string    `json:"hash"`
	Size         int64     `json:"size"`
	RefCount     int       `json:"ref_count"`
	CreatedAt    time.Time `json:"created_at"`
	LastAccessed time.Time `json:"last_accessed"`
	FileIDs      []string  `json:"file_ids"`
}

ChunkInfo represents information about a data chunk

type ChunkSize

type ChunkSize int64

ChunkSize represents the size of chunks for deduplication

const (
	ChunkSizeSmall  ChunkSize = 64 * 1024   // 64KB
	ChunkSizeMedium ChunkSize = 256 * 1024  // 256KB
	ChunkSizeLarge  ChunkSize = 1024 * 1024 // 1MB
)

type CompressionManager

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

CompressionManager manages file compression

func NewCompressionManager

func NewCompressionManager(client *client.Client, configDir string) *CompressionManager

NewCompressionManager creates a new compression manager

func (*CompressionManager) CompressFile

func (cm *CompressionManager) CompressFile(fileID string, algorithm string, level int) (*CompressionResult, error)

CompressFile compresses a file

func (*CompressionManager) DecompressFile

func (cm *CompressionManager) DecompressFile(fileID string, algorithm string) ([]byte, error)

DecompressFile decompresses a file

func (*CompressionManager) GetCompressionSettings

func (cm *CompressionManager) GetCompressionSettings() *CompressionSettings

GetCompressionSettings returns current compression settings

func (*CompressionManager) GetCompressionStats

func (cm *CompressionManager) GetCompressionStats() *CompressionStats

GetCompressionStats returns compression statistics

func (*CompressionManager) ResetStats

func (cm *CompressionManager) ResetStats()

ResetStats resets compression statistics

func (*CompressionManager) ShouldCompress

func (cm *CompressionManager) ShouldCompress(fileSize int64, contentType string) bool

ShouldCompress determines if a file should be compressed

func (*CompressionManager) UpdateCompressionSettings

func (cm *CompressionManager) UpdateCompressionSettings(settings *CompressionSettings) error

UpdateCompressionSettings updates compression settings

type CompressionResult

type CompressionResult struct {
	OriginalSize     int64         `json:"original_size"`
	CompressedSize   int64         `json:"compressed_size"`
	CompressionRatio float64       `json:"compression_ratio"`
	Algorithm        string        `json:"algorithm"`
	Level            int           `json:"level"`
	TimeTaken        time.Duration `json:"time_taken"`
	Success          bool          `json:"success"`
	Error            string        `json:"error,omitempty"`
}

CompressionResult represents the result of a compression operation

type CompressionSettings

type CompressionSettings struct {
	Enabled          bool   `json:"enabled"`
	Algorithm        string `json:"algorithm"` // "gzip", "zlib", "none"
	Level            int    `json:"level"`     // 1-9 for gzip/zlib
	MinSize          int64  `json:"min_size"`  // Minimum file size to compress
	MaxSize          int64  `json:"max_size"`  // Maximum file size to compress
	AutoCompress     bool   `json:"auto_compress"`
	CompressOnUpload bool   `json:"compress_on_upload"`
}

CompressionSettings represents compression configuration

type CompressionStats

type CompressionStats struct {
	TotalFiles          int64     `json:"total_files"`
	CompressedFiles     int64     `json:"compressed_files"`
	UncompressedFiles   int64     `json:"uncompressed_files"`
	TotalOriginalSize   int64     `json:"total_original_size"`
	TotalCompressedSize int64     `json:"total_compressed_size"`
	CompressionRatio    float64   `json:"compression_ratio"`
	SpaceSaved          int64     `json:"space_saved"`
	LastUpdated         time.Time `json:"last_updated"`
}

CompressionStats represents compression statistics

type DeduplicationManager

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

DeduplicationManager manages file deduplication

func NewDeduplicationManager

func NewDeduplicationManager(client *client.Client, configDir string) *DeduplicationManager

NewDeduplicationManager creates a new deduplication manager

func (*DeduplicationManager) CleanupUnusedChunks

func (dm *DeduplicationManager) CleanupUnusedChunks() error

CleanupUnusedChunks removes chunks with no references

func (*DeduplicationManager) DeduplicateFile

func (dm *DeduplicationManager) DeduplicateFile(fileID string, chunkSize ChunkSize) (*DeduplicationResult, error)

DeduplicateFile deduplicates a file by chunking it

func (*DeduplicationManager) GetChunkInfo

func (dm *DeduplicationManager) GetChunkInfo(chunkHash string) (*ChunkInfo, error)

GetChunkInfo returns information about a specific chunk

func (*DeduplicationManager) GetDeduplicationStats

func (dm *DeduplicationManager) GetDeduplicationStats() *DeduplicationStats

GetDeduplicationStats returns deduplication statistics

func (*DeduplicationManager) ListChunks

func (dm *DeduplicationManager) ListChunks() []*ChunkInfo

ListChunks returns all chunks with their information

func (*DeduplicationManager) ReconstructFile

func (dm *DeduplicationManager) ReconstructFile(fileID string) ([]byte, error)

ReconstructFile reconstructs a file from its chunks

func (*DeduplicationManager) RemoveFileChunks

func (dm *DeduplicationManager) RemoveFileChunks(fileID string) error

RemoveFileChunks removes chunks associated with a file

func (*DeduplicationManager) ResetStats

func (dm *DeduplicationManager) ResetStats()

ResetStats resets deduplication statistics

type DeduplicationResult

type DeduplicationResult struct {
	FileID             string        `json:"file_id"`
	OriginalSize       int64         `json:"original_size"`
	DeduplicatedSize   int64         `json:"deduplicated_size"`
	ChunksCreated      int           `json:"chunks_created"`
	ChunksReused       int           `json:"chunks_reused"`
	SpaceSaved         int64         `json:"space_saved"`
	DeduplicationRatio float64       `json:"deduplication_ratio"`
	TimeTaken          time.Duration `json:"time_taken"`
	Success            bool          `json:"success"`
	Error              string        `json:"error,omitempty"`
}

DeduplicationResult represents the result of a deduplication operation

type DeduplicationStats

type DeduplicationStats struct {
	TotalFiles         int64     `json:"total_files"`
	UniqueChunks       int64     `json:"unique_chunks"`
	DuplicateChunks    int64     `json:"duplicate_chunks"`
	TotalSize          int64     `json:"total_size"`
	DeduplicatedSize   int64     `json:"deduplicated_size"`
	SpaceSaved         int64     `json:"space_saved"`
	DeduplicationRatio float64   `json:"deduplication_ratio"`
	LastUpdated        time.Time `json:"last_updated"`
}

DeduplicationStats represents deduplication statistics

type FileShare

type FileShare struct {
	ID           string                 `json:"id"`
	FileID       string                 `json:"file_id"`
	SharedBy     string                 `json:"shared_by"`
	SharedWith   []string               `json:"shared_with"`
	Permissions  []string               `json:"permissions"` // "read", "write", "delete"
	ExpiresAt    time.Time              `json:"expires_at"`
	CreatedAt    time.Time              `json:"created_at"`
	AccessCount  int                    `json:"access_count"`
	LastAccessed time.Time              `json:"last_accessed"`
	IsPublic     bool                   `json:"is_public"`
	PublicURL    string                 `json:"public_url,omitempty"`
	Metadata     map[string]interface{} `json:"metadata"`
}

FileShare represents a shared file

type FileVersion

type FileVersion struct {
	ID          string                 `json:"id"`
	FileID      string                 `json:"file_id"`
	Version     int                    `json:"version"`
	Size        int64                  `json:"size"`
	Hash        string                 `json:"hash"`
	CreatedAt   time.Time              `json:"created_at"`
	CreatedBy   string                 `json:"created_by"`
	Description string                 `json:"description"`
	Tags        []string               `json:"tags"`
	Metadata    map[string]interface{} `json:"metadata"`
	IsCurrent   bool                   `json:"is_current"`
}

FileVersion represents a version of a file

type ShareManager

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

ShareManager manages file sharing

func NewShareManager

func NewShareManager(client *client.Client, configDir string) *ShareManager

NewShareManager creates a new share manager

func (*ShareManager) AccessShare

func (sm *ShareManager) AccessShare(shareID, userID string) error

AccessShare records access to a shared file

func (*ShareManager) AddUserToShare

func (sm *ShareManager) AddUserToShare(shareID, userID string) error

AddUserToShare adds a user to an existing share

func (*ShareManager) CleanupExpiredShares

func (sm *ShareManager) CleanupExpiredShares() error

CleanupExpiredShares removes expired shares

func (*ShareManager) DeleteShare

func (sm *ShareManager) DeleteShare(shareID string) error

DeleteShare permanently deletes a share

func (*ShareManager) GetShare

func (sm *ShareManager) GetShare(shareID string) (*FileShare, error)

GetShare returns a share by ID

func (*ShareManager) GetShareStats

func (sm *ShareManager) GetShareStats() *ShareStats

GetShareStats returns sharing statistics

func (*ShareManager) GetSharedWithUser

func (sm *ShareManager) GetSharedWithUser(userID string) ([]*FileShare, error)

GetSharedWithUser returns all shares shared with a user

func (*ShareManager) GetSharesByUser

func (sm *ShareManager) GetSharesByUser(userID string) ([]*FileShare, error)

GetSharesByUser returns all shares created by a user

func (*ShareManager) GetSharesForFile

func (sm *ShareManager) GetSharesForFile(fileID string) ([]*FileShare, error)

GetSharesForFile returns all shares for a file

func (*ShareManager) RemoveUserFromShare

func (sm *ShareManager) RemoveUserFromShare(shareID, userID string) error

RemoveUserFromShare removes a user from a share

func (*ShareManager) RevokeShare

func (sm *ShareManager) RevokeShare(shareID string) error

RevokeShare revokes a share

func (*ShareManager) ShareFile

func (sm *ShareManager) ShareFile(fileID, sharedBy string, sharedWith []string, permissions []string, expiresIn time.Duration) (*FileShare, error)

ShareFile shares a file with specific users

func (*ShareManager) ShareFilePublicly

func (sm *ShareManager) ShareFilePublicly(fileID, sharedBy string, permissions []string, expiresIn time.Duration) (*FileShare, error)

ShareFilePublicly shares a file publicly

func (*ShareManager) UpdateSharePermissions

func (sm *ShareManager) UpdateSharePermissions(shareID string, permissions []string) error

UpdateSharePermissions updates permissions for a share

type SharePermission

type SharePermission struct {
	UserID      string    `json:"user_id"`
	Username    string    `json:"username"`
	Permissions []string  `json:"permissions"`
	GrantedAt   time.Time `json:"granted_at"`
	GrantedBy   string    `json:"granted_by"`
}

SharePermission represents sharing permissions

type ShareStats

type ShareStats struct {
	TotalShares   int `json:"total_shares"`
	PublicShares  int `json:"public_shares"`
	PrivateShares int `json:"private_shares"`
	ExpiredShares int `json:"expired_shares"`
	ActiveShares  int `json:"active_shares"`
	TotalAccesses int `json:"total_accesses"`
}

ShareStats represents sharing statistics

type StreamInfo

type StreamInfo struct {
	ID               string                 `json:"id"`
	FileID           string                 `json:"file_id"`
	UserID           string                 `json:"user_id"`
	StreamType       string                 `json:"stream_type"` // "upload", "download"
	Status           string                 `json:"status"`      // "active", "paused", "completed", "error"
	Progress         float64                `json:"progress"`    // 0.0 to 1.0
	BytesTransferred int64                  `json:"bytes_transferred"`
	TotalBytes       int64                  `json:"total_bytes"`
	StartTime        time.Time              `json:"start_time"`
	LastUpdate       time.Time              `json:"last_update"`
	EndTime          *time.Time             `json:"end_time,omitempty"`
	Error            string                 `json:"error,omitempty"`
	Metadata         map[string]interface{} `json:"metadata"`
}

StreamInfo represents information about an active stream

type StreamProgress

type StreamProgress struct {
	StreamID         string        `json:"stream_id"`
	Progress         float64       `json:"progress"`
	BytesTransferred int64         `json:"bytes_transferred"`
	TotalBytes       int64         `json:"total_bytes"`
	Speed            float64       `json:"speed"` // bytes per second
	ETA              time.Duration `json:"eta"`   // estimated time remaining
	Status           string        `json:"status"`
}

StreamProgress represents progress information for a stream

type StreamingManager

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

StreamingManager manages file streaming

func NewStreamingManager

func NewStreamingManager(client *client.Client, configDir string) *StreamingManager

NewStreamingManager creates a new streaming manager

func (*StreamingManager) CancelStream

func (sm *StreamingManager) CancelStream(streamID string) error

CancelStream cancels a stream

func (*StreamingManager) GetStream

func (sm *StreamingManager) GetStream(streamID string) (*StreamInfo, error)

GetStream returns information about a stream

func (*StreamingManager) GetStreamProgress

func (sm *StreamingManager) GetStreamProgress(streamID string) (*StreamProgress, error)

GetStreamProgress returns progress information for a stream

func (*StreamingManager) GetStreamingSettings

func (sm *StreamingManager) GetStreamingSettings() *StreamingSettings

GetStreamingSettings returns current streaming settings

func (*StreamingManager) ListStreams

func (sm *StreamingManager) ListStreams() []*StreamInfo

ListStreams returns all active streams

func (*StreamingManager) PauseStream

func (sm *StreamingManager) PauseStream(streamID string) error

PauseStream pauses a stream

func (*StreamingManager) ResumeStream

func (sm *StreamingManager) ResumeStream(streamID string) error

ResumeStream resumes a paused stream

func (*StreamingManager) StartDownloadStream

func (sm *StreamingManager) StartDownloadStream(fileID, userID string, writer io.Writer) (*StreamInfo, error)

StartDownloadStream starts streaming download of a file

func (*StreamingManager) StartUploadStream

func (sm *StreamingManager) StartUploadStream(fileID, userID string, reader io.Reader, totalSize int64) (*StreamInfo, error)

StartUploadStream starts streaming upload of a file

func (*StreamingManager) UpdateStreamingSettings

func (sm *StreamingManager) UpdateStreamingSettings(settings *StreamingSettings) error

UpdateStreamingSettings updates streaming settings

type StreamingSettings

type StreamingSettings struct {
	ChunkSize         int64         `json:"chunk_size"`         // Size of each chunk
	BufferSize        int64         `json:"buffer_size"`        // Buffer size for streaming
	MaxConcurrent     int           `json:"max_concurrent"`     // Max concurrent streams
	Timeout           time.Duration `json:"timeout"`            // Stream timeout
	RetryAttempts     int           `json:"retry_attempts"`     // Number of retry attempts
	RetryDelay        time.Duration `json:"retry_delay"`        // Delay between retries
	EnableCompression bool          `json:"enable_compression"` // Enable streaming compression
	EnableEncryption  bool          `json:"enable_encryption"`  // Enable streaming encryption
}

StreamingSettings represents streaming configuration

type StreamingStats

type StreamingStats struct {
	TotalStreams       int64     `json:"total_streams"`
	ActiveStreams      int64     `json:"active_streams"`
	CompletedStreams   int64     `json:"completed_streams"`
	FailedStreams      int64     `json:"failed_streams"`
	TotalBytesStreamed int64     `json:"total_bytes_streamed"`
	AverageSpeed       float64   `json:"average_speed"` // bytes per second
	LastUpdated        time.Time `json:"last_updated"`
}

StreamingStats represents streaming statistics

type VersionComparison

type VersionComparison struct {
	FileID   string        `json:"file_id"`
	Version1 *FileVersion  `json:"version1"`
	Version2 *FileVersion  `json:"version2"`
	SizeDiff int64         `json:"size_diff"`
	HashDiff bool          `json:"hash_diff"`
	TimeDiff time.Duration `json:"time_diff"`
	TagDiff  []string      `json:"tag_diff"`
}

VersionComparison represents a comparison between two versions

type VersionInfo

type VersionInfo struct {
	FileID         string         `json:"file_id"`
	CurrentVersion int            `json:"current_version"`
	TotalVersions  int            `json:"total_versions"`
	Versions       []*FileVersion `json:"versions"`
	CreatedAt      time.Time      `json:"created_at"`
	UpdatedAt      time.Time      `json:"updated_at"`
}

VersionInfo represents version information for a file

type VersionManager

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

VersionManager manages file versioning

func NewVersionManager

func NewVersionManager(client *client.Client, configDir string) *VersionManager

NewVersionManager creates a new version manager

func (*VersionManager) CompareVersions

func (vm *VersionManager) CompareVersions(fileID string, version1, version2 int) (*VersionComparison, error)

CompareVersions compares two versions of a file

func (*VersionManager) CreateVersion

func (vm *VersionManager) CreateVersion(fileID, description, createdBy string, tags []string) (*FileVersion, error)

CreateVersion creates a new version of a file

func (*VersionManager) DeleteVersion

func (vm *VersionManager) DeleteVersion(fileID string, versionNumber int) error

DeleteVersion deletes a specific version

func (*VersionManager) GetCurrentVersion

func (vm *VersionManager) GetCurrentVersion(fileID string) (*FileVersion, error)

GetCurrentVersion returns the current version of a file

func (*VersionManager) GetVersions

func (vm *VersionManager) GetVersions(fileID string) ([]*FileVersion, error)

GetVersions returns all versions for a file

func (*VersionManager) ListAllVersions

func (vm *VersionManager) ListAllVersions() []*VersionInfo

ListAllVersions returns version info for all files

func (*VersionManager) RestoreVersion

func (vm *VersionManager) RestoreVersion(fileID string, versionNumber int) error

RestoreVersion restores a specific version of a file

Jump to

Keyboard shortcuts

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