filewriter

package
v0.208.2 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 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 Backup added in v0.207.0

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

Backup handles file backup operations

func NewBackup added in v0.207.0

func NewBackup(backupDir string) *Backup

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

func (*Backup) CleanupBackup added in v0.207.0

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

CleanupBackup removes a backup file

func (*Backup) CreateBackup added in v0.207.0

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

CreateBackup creates a backup of the original file

func (*Backup) RestoreBackup added in v0.207.0

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

RestoreBackup restores a backup to the original location

type ChunkBuffer added in v0.207.0

type ChunkBuffer 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)
}

ChunkBuffer defines the interface for handling chunked file writes

func NewStreamingChunkBuffer added in v0.207.0

func NewStreamingChunkBuffer(tempDir string, writer FileWriter) ChunkBuffer

NewStreamingChunkBuffer creates a new StreamingChunkBuffer

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 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 *Backup) 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 StreamingChunkBuffer added in v0.207.0

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

StreamingChunkBuffer implements ChunkBuffer with safe streaming

func (*StreamingChunkBuffer) CleanupSession added in v0.207.0

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

CleanupSession removes an active session and cleans up resources

func (*StreamingChunkBuffer) FinalizeChunks added in v0.207.0

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

FinalizeChunks completes a chunked write session and moves to target location

func (*StreamingChunkBuffer) GetSessionInfo added in v0.207.0

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

GetSessionInfo returns information about an active session

func (*StreamingChunkBuffer) WriteChunk added in v0.207.0

func (cm *StreamingChunkBuffer) 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