filewriter

package
v0.204.2 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChunkManager

type ChunkManager interface {
	WriteChunk(ctx context.Context, req ChunkWriteRequest) error
	FinalizeChunks(ctx context.Context, sessionID string, targetPath string) (*WriteResult, error)
	CleanupSession(sessionID string) error
	GetSessionInfo(sessionID string) (*ChunkSessionInfo, error)
}

ChunkManager defines the interface for handling chunked file writes

func NewStreamingChunkManager

func NewStreamingChunkManager(tempDir string, writer FileWriter) ChunkManager

NewStreamingChunkManager creates a new StreamingChunkManager

type ChunkSession

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

ChunkSession represents an active chunked writing session

type ChunkSessionInfo

type ChunkSessionInfo struct {
	SessionID   string
	TotalChunks int
	Created     bool
}

ChunkSessionInfo provides information about an active chunk session

type ChunkWriteRequest

type ChunkWriteRequest struct {
	SessionID  string
	ChunkIndex int
	Data       []byte
	IsLast     bool
}

ChunkWriteRequest represents a chunk write operation

type DefaultBackupManager

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

DefaultBackupManager handles file backup operations

func NewBackupManager

func NewBackupManager(backupDir string) *DefaultBackupManager

NewBackupManager creates a new DefaultBackupManager writing into backupDir - the per-project runtime backups dir (~/.infer/projects/<project-slug>/backups).

func (*DefaultBackupManager) CleanupBackup

func (b *DefaultBackupManager) CleanupBackup(backupPath string) error

CleanupBackup removes a backup file

func (*DefaultBackupManager) CreateBackup

func (b *DefaultBackupManager) CreateBackup(ctx context.Context, originalPath string) (string, error)

CreateBackup creates a backup of the original file

func (*DefaultBackupManager) RestoreBackup

func (b *DefaultBackupManager) RestoreBackup(ctx context.Context, backupPath string, originalPath string) error

RestoreBackup restores a backup to the original location

type DefaultPathValidator

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

DefaultPathValidator validates file paths for security and accessibility

func NewPathValidator

func NewPathValidator(cfg *config.Config) *DefaultPathValidator

NewPathValidator creates a new DefaultPathValidator

func (*DefaultPathValidator) IsInSandbox

func (v *DefaultPathValidator) IsInSandbox(path string) bool

IsInSandbox checks if a path is within configured sandbox directories

func (*DefaultPathValidator) IsWritable

func (v *DefaultPathValidator) IsWritable(path string) bool

IsWritable checks if a path can be written to

func (*DefaultPathValidator) Validate

func (v *DefaultPathValidator) Validate(path string) error

Validate checks if a path is valid and secure for file operations

type FileWriter

type FileWriter interface {
	Write(ctx context.Context, req WriteRequest) (*WriteResult, error)
	ValidatePath(path string) error
}

FileWriter defines the interface for file writing operations

func NewSafeFileWriter

func NewSafeFileWriter(validator *DefaultPathValidator, backupManager *DefaultBackupManager) FileWriter

NewSafeFileWriter creates a new SafeFileWriter

type SafeFileWriter

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

SafeFileWriter implements FileWriter with atomic operations

func (*SafeFileWriter) ValidatePath

func (w *SafeFileWriter) ValidatePath(path string) error

ValidatePath validates if a path is safe for writing

func (*SafeFileWriter) Write

Write performs an atomic file write operation

type StreamingChunkManager

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

StreamingChunkManager implements ChunkManager with safe streaming

func (*StreamingChunkManager) CleanupSession

func (cm *StreamingChunkManager) CleanupSession(sessionID string) error

CleanupSession removes an active session and cleans up resources

func (*StreamingChunkManager) FinalizeChunks

func (cm *StreamingChunkManager) FinalizeChunks(ctx context.Context, sessionID string, targetPath string) (*WriteResult, error)

FinalizeChunks completes a chunked write session and moves to target location

func (*StreamingChunkManager) GetSessionInfo

func (cm *StreamingChunkManager) GetSessionInfo(sessionID string) (*ChunkSessionInfo, error)

GetSessionInfo returns information about an active session

func (*StreamingChunkManager) WriteChunk

func (cm *StreamingChunkManager) WriteChunk(ctx context.Context, req ChunkWriteRequest) error

WriteChunk writes a chunk to the session's temp file

type WriteRequest

type WriteRequest struct {
	Path      string
	Content   string
	Overwrite bool
	Backup    bool
}

WriteRequest represents a file write operation request

type WriteResult

type WriteResult struct {
	Path         string
	BytesWritten int64
	BackupPath   string
	Created      bool
}

WriteResult represents the result of a file write operation

Jump to

Keyboard shortcuts

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