item

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package item writes and removes items: the deploy flow of decision 0004 (content into the blob store, then the item and its blob reference in one transaction), checksum deploy, folders, client checksums and deletion into the trash can (decision 0010). Every write calls the repository format's hooks (internal/format, decision 0032): Inspect once the content is stored, then Admit and the hooks inside the write's transaction. A format indexes what it deploys, and a delete prunes the package index for every format.

Index

Constants

View Source
const (
	// MaxExplodeBytes bounds both the uploaded archive and the total of its
	// extracted entries.
	MaxExplodeBytes = 4 << 30
	// MaxExplodeEntries bounds the entries of one archive.
	MaxExplodeEntries = 10_000
)

Limits on exploding an archive. Entry sizes in an archive's headers are the uploader's claim, so the extracted bytes are counted as they are written, which is what stops a zip bomb.

View Source
const (
	NotArchive = archive.KindNone
	Zip        = archive.KindZip
	Tar        = archive.KindTar
	TarGz      = archive.KindTarGz
)

Archive kinds; NotArchive is a file none of them.

View Source
const (
	KindCacheCleanupSchedule = "remote.cache-cleanup-schedule"
	KindCacheCleanup         = "remote.cache-cleanup"
	CacheCleanupInterval     = time.Hour
	CacheCleanupBatch        = 128
)
View Source
const (
	PropTrashOriginalRepository = "trash.originalRepository"
	PropTrashRestoredTime       = "trash.restoredTime"
)

The properties a restore sets on every item it brings back. 7.x lists both on restored items (RTFACT-29810); their values are 6.20's: the key of the repository the item was deleted from, and the restore's time in Unix milliseconds (TrashService, TrashInterceptor.afterMove).

View Source
const (
	LevelInfo    = "INFO"
	LevelWarning = "WARNING"
	LevelError   = "ERROR"
)

Levels of a copy or move message (the CopyOrMoveMessage enum).

Variables

View Source
var (
	ErrRemoteLength           = errors.New("item: remote response length mismatch")
	ErrRemoteMIME             = errors.New("item: remote response mime mismatch")
	ErrRemoteLimit            = errors.New("item: remote response exceeds limit")
	ErrRemoteChecksumRequired = errors.New("item: upstream checksum required")
)

Remote ingestion errors are source failures, never negative cache entries.

View Source
var (
	// ErrChecksumMismatch is a declared checksum that differs from the
	// content under the client-checksums policy (409).
	ErrChecksumMismatch = errors.New("item: checksum mismatch")
	// ErrBadChecksum is a declared checksum that is not hex of a known
	// length (400).
	ErrBadChecksum = errors.New("item: malformed checksum")
	// ErrNoBlob is a checksum deploy for content the server does not hold
	// (404, after which the client uploads the content).
	ErrNoBlob = errors.New("item: no stored content has the checksum")
	// ErrConflict is a file where a folder must go, or the reverse (409).
	ErrConflict = errors.New("item: path conflict")
	// ErrCollected is content garbage collection removed while it was being
	// deployed: nothing was stored, and the deploy must be repeated (503,
	// which the JFrog CLI retries).
	ErrCollected = errors.New(
		"item: the content was removed by garbage collection while it was deployed; deploy it again",
	)
	// ErrNotFound is a missing item.
	ErrNotFound = store.ErrNotFound
	// ErrExists is a deploy with IfAbsent to a path that holds an item.
	ErrExists = errors.New("item: the path already holds an item")
)

Errors the HTTP layer maps onto statuses.

View Source
var ErrBadArchive = archive.ErrUnusable

ErrBadArchive is an upload that is not a usable archive: an unknown or corrupt format, an entry escaping its folder, or limits exceeded (400).

View Source
var ErrDuplicateKind = errors.New("item: two formats claim one kind of work")

ErrDuplicateKind reports two formats that claim one kind of work.

View Source
var ErrInvalidTransfer = errors.New("item: invalid copy or move")

ErrInvalidTransfer is a copy or move that cannot run at all: onto itself, into its own subtree, or below a file at the target (400).

View Source
var ErrNoReindex = errors.New("item: the format keeps no index to rebuild")

ErrNoReindex reports a package type whose format keeps no index to rebuild.

View Source
var ErrNoSource = fmt.Errorf("item: no source: %w", store.ErrNotFound)

ErrNoSource is a copy or move whose source does not exist (400 with a report). It wraps store.ErrNotFound, so a caller that tests for that, such as a promotion whose file went in the meantime, still sees a miss.

View Source
var ErrOverwriteDenied = errors.New("item: no permission to overwrite")

ErrOverwriteDenied is a deploy or an explode that would replace existing files the caller may not delete (403). The service returns it as an *OverwriteDeniedError, which names the file and the caller.

Functions

func DeclaresContentOf

func DeclaresContentOf(declared types.Checksums, f types.Item) bool

DeclaresContentOf reports whether parsed declared checksums name f's content: a SHA-1 or SHA-256 that equals f's, and neither that differs. MD5 and SHA-512 do not count, as in Artifactory 6.20's isFileOverwrite, which compares the SHA-1 and SHA-256 alone.

func FolderDownload

func FolderDownload(ctx context.Context, st store.Store) (types.FolderDownloadSettings, error)

FolderDownload reads the folder download setting, with Artifactory's defaults for what is unset: off, 1024 MB and 5000 files.

func MergeRemoteProperties

func MergeRemoteProperties(
	current types.Properties,
	prior *types.RemoteSmartState,
	incoming types.Properties,
	at time.Time,
) (types.Properties, *types.RemoteSmartState)

MergeRemoteProperties changes only values which still match the previous synchronized value. A local edit or deletion permanently takes ownership of that key for this source lifetime; upstream disappearance cannot erase it.

func MimeType

func MimeType(name string) string

MimeType is the media type recorded for a file name.

func ParseChecksums

func ParseChecksums(c types.Checksums) (types.Checksums, error)

ParseChecksums checks declared checksums: lowercase hex of the length of their algorithm, or empty.

func ServedChecksum

func ServedChecksum(c repo.Config, it types.Item, a Algorithm) string

ServedChecksum is the value of the file it that its sidecar for algorithm a answers a GET with, where c is the repository that holds the file, as Artifactory's LocalRepoChecksumPolicy.getChecksum (6.20) chooses it. Under client-checksums it is the client's checksum, and empty while the client has sent none, so the sidecar answers 404 until one is deployed, as local-repositories documents for 7.x. Under server-generated-checksums, for a file named maven-metadata.xml in any repository (the server computes those checksums, and drops a client's), and in a remote cache, which that policy does not govern, it is the computed checksum.

func TrashEnabled

func TrashEnabled(ctx context.Context, st store.Store) (bool, error)

TrashEnabled reads the trash can setting; unset means on, as in Artifactory.

Types

type Algorithm

type Algorithm string

Algorithm names a checksum sidecar's digest.

const (
	SHA256 Algorithm = "sha256"
	SHA512 Algorithm = "sha512"
	SHA1   Algorithm = "sha1"
	MD5    Algorithm = "md5"
)

Sidecar algorithms, by file extension.

func Sidecar

func Sidecar(p string) (artifact string, a Algorithm, ok bool)

Sidecar splits a checksum sidecar path ("a/b.jar.sha1") into the artifact's path and the algorithm; ok is false for any other path.

func (Algorithm) Of

func (a Algorithm) Of(c types.Checksums) string

Of returns the digest a of c.

type ArchiveKind

type ArchiveKind = archive.Kind

ArchiveKind is an archive container format.

func ParseArchiveKind

func ParseArchiveKind(s string) (ArchiveKind, bool)

ParseArchiveKind reads an archiveType parameter (zip, tar, tar.gz, tgz).

type CacheResult

type CacheResult struct {
	Declared types.Checksums
	Entry    types.RemoteCacheEntry
	Item     types.Item
	Info     blob.Info
	Body     io.ReadSeekCloser
}

CacheResult is either committed content or an owned transient reader. Close Body after a no-store response; closing removes its temporary file.

type CacheUpload

type CacheUpload struct {
	// SmartProperties is a complete validated peer snapshot. Merge it inside
	// the publication transaction so a concurrent local annotation wins.
	SmartProperties        *types.Properties
	SmartPropertiesStarted time.Time
	// Expected comes from authoritative protocol metadata, not optional remote
	// headers. It is enforced even when their checksum policy says ignore.
	Expected types.Checksums
	// Validate inspects complete bytes outside SQL, before either publication
	// or transient delivery. It must not retain or close its reader.
	Validate   func(context.Context, io.ReadSeeker, int64) error
	Token      types.RemoteCacheToken
	Repo       repo.Config
	Body       io.Reader
	Kind       types.RemoteKind
	Declared   types.Checksums
	Properties types.Properties
	// PublishMetadata keeps protocol metadata in its native item/index layout
	// while retaining metadata expiry and zap behavior. Ordinary raw upstream
	// metadata deliberately stays outside the derived package tree.
	PublishMetadata bool
	Length          int64 // -1 means unknown; zero requires an empty body
	// ExpectedContentType is a trusted format-adapter hint for raw metadata
	// whose route has no extension (for example a PyPI HTML simple index).
	// Never derive it from the upstream Content-Type or arbitrary caller Accept.
	ExpectedContentType  string
	ExpectedContentTypes []string
	RemoteURL            string // sanitized origin, without userinfo or query
	ContentType          string
	ETag                 string
	LastModified         string
	CacheControl         string
	Vary                 string
	By                   string
	NoStore              bool
	// MaxBytes bounds transient storage and parsed metadata, zero means the
	// default 64MiB for metadata and no additional artifact size limit.
	MaxBytes     int64
	CheckCurrent func(context.Context, store.Store) error
}

CacheUpload is a complete upstream response awaiting validation/publication. Token was obtained before network I/O. CheckCurrent rechecks authorization and effective proxy/certificate revision without network I/O in the transaction.

type Deploy

type Deploy struct {
	Target
	// Body is streamed into the blob store; a checksum deploy ignores it.
	Body io.Reader
	// ResolvePath derives a destination from the format inspection before any
	// transaction begins, for uploads whose content names their canonical path.
	// Its error refuses the write without publishing items or package metadata.
	ResolvePath func(inspection any) (string, error)
	// Declared holds the checksums the client sent.
	Declared types.Checksums
	// Properties are set on the item (matrix parameters).
	Properties types.Properties
	By         string
	// IfAbsent stores the file only when nothing is at its path, and
	// refuses with ErrExists otherwise, for a file published once, such as
	// an npm version's tarball. The check is made in the write's
	// transaction, after the content is stored.
	IfAbsent bool
	// CanOverwritePath, when set, is the caller's right to replace the file
	// at a full path. It is asked about the path the format admits, which a
	// format may rename (Maven's unique snapshots), so a caller's check of
	// the path it sent does not cover it; an *OverwriteDeniedError naming
	// that path and By when it says no.
	CanOverwritePath func(fullPath string) bool
	// OverwriteIdentical replaces a file without CanOverwritePath's consent
	// when the deploy declares the file's content (DeclaresContentOf) and
	// stores exactly that content, as Artifactory lets a re-deploy of
	// identical content through without the delete permission. The stored
	// content is compared too, because a declaration alone is only the
	// client's claim: under server-generated-checksums nothing checks it.
	OverwriteIdentical bool

	// Trusted records the computed checksums as the client's, as
	// Artifactory does for the files it writes itself (6.20
	// InternalArtifactoryRequest.isTrustServerChecksums) and for a checksum
	// deploy. A file the server writes, such as a build-info document or a
	// registry's manifest, has no client to send its checksums, and under
	// client-checksums its checksum files would otherwise answer 404.
	Trusted bool
	// Reusable, when set, decides whether a checksum deploy may store the
	// content it found; when it says no, the deploy fails with ErrNoBlob as
	// if the content were not there, so the answer does not reveal that it
	// is. A caller's checksum deploy sets it (knowing a checksum must not
	// copy content the caller cannot read); a write that already holds the
	// content, such as a registry upload's completion, leaves it nil.
	Reusable func(ctx context.Context, b types.Blob) (bool, error)
	// contains filtered or unexported fields
}

Deploy is a file write.

type Enqueuer

type Enqueuer interface {
	Enqueue(ctx context.Context, kind, key string, payload []byte) error
}

Enqueuer asks the persistent work queue for work; *work.Queue is one.

type Explode

type Explode struct {
	Deploy
	// Atomic stores every entry or none.
	Atomic bool
	// CanOverwrite is the caller's right to replace existing files.
	CanOverwrite bool
}

Explode is a deploy whose body is an archive: its entries are deployed into the folder of Path, and the archive itself is not stored.

type Freshener

type Freshener interface {
	EnsureFresh(ctx context.Context, kind, key string) error
}

Freshener brings derived work up to date before a reader reads what it derives; *work.Queue is one.

type Message

type Message struct {
	Level string
	Text  string
}

Message is one line of a copy or move report.

type OverwriteDeniedError

type OverwriteDeniedError struct {
	// Repo is the key of the repository that holds the file.
	Repo string
	// Path is the file's path in it, where the format stored the write,
	// which for a Maven unique snapshot is not the path sent.
	Path string
	// User is the caller's name: auth.AnonymousUser for an anonymous one.
	User string
}

OverwriteDeniedError is a write refused because it would replace a file the caller may not delete. Its text is Artifactory 7.x's, which clients match rather than read: Poetry's publish --skip-existing takes a 403 whose text holds "overwrite artifact" for a file that is already there, and fails on any other wording.

func (*OverwriteDeniedError) Error

func (e *OverwriteDeniedError) Error() string

func (*OverwriteDeniedError) Unwrap

func (e *OverwriteDeniedError) Unwrap() error

type Service

type Service struct {
	Store store.Store
	Blobs blob.Store
	// Now supplies the time; nil means time.Now.
	Now func() time.Time
	// Formats returns a package type's format; nil means formats.For.
	// Tests substitute formats that record or fail their hooks.
	Formats func(repo.PackageType) format.Handler
	// Work takes the derived work formats ask for. Nil writes it to the
	// store's queue directly, where every node's workers find it on their
	// next poll; a queue also wakes its own idle workers on commit.
	Work Enqueuer
	// Periodic names the kinds of derived work RegisterWork runs on a timer
	// rather than as soon as they are due, each with its interval
	// (work.Queue.HandleEvery).
	Periodic map[string]time.Duration
	// ReindexAuthorize checks the original caller of queued remote maintenance.
	// A remote job fails closed when this runtime hook is absent.
	ReindexAuthorize func(context.Context, repo.Config, format.WorkRequest) error
}

Service writes items into a store and its blob store.

func (*Service) Annotate

func (s *Service) Annotate(
	ctx context.Context,
	c repo.Config,
	it types.Item,
	set types.Properties,
	remove []string,
) error

Annotate changes the properties of it, an item of c: set replaces the values of its keys and remove drops keys. It runs inside ctx's transaction, or one of its own, once the format admits the change (format.AnnotationAdmitter), and with the format's Annotated hook, so a format whose index follows properties stays in step whichever API made the change.

func (*Service) ArchiveEntry

func (s *Service) ArchiveEntry(
	ctx context.Context,
	it types.Item,
	entry string,
	serve func(size int64, r io.Reader) error,
) error

ArchiveEntry finds the entry at entry inside the archive file it and calls serve with its size and content. ErrNotFound when the file is not an archive or has no such entry.

func (*Service) ArchiveFiles

func (s *Service) ArchiveFiles(
	ctx context.Context,
	files []types.Item,
	base string,
	kind ArchiveKind,
	sums bool,
	w io.Writer,
) error

ArchiveFiles writes files to w as one archive of kind, each named by its path relative to base, with ".md5", ".sha1" and ".sha256" sidecars when sums is set. The archive is streamed: nothing is buffered beyond one file's copy buffer.

func (*Service) Cache

func (s *Service) Cache(ctx context.Context, u CacheUpload) (CacheResult, error)

Cache streams and validates outside SQL, then atomically publishes item/index hooks and raw cache state. A failed refresh never changes the former entry.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, t Target, by string) (store.DeleteResult, error)

Delete removes the item at t.Path and everything below it ("" is the repository root), with the sidecars its format keeps with each file (format.SidecarKeeper). Files of local repositories go to the trash can when it is on, keeping their blob references for a restore; otherwise, and for remote caches, the references are released for garbage collection.

func (*Service) Deploy

func (s *Service) Deploy(ctx context.Context, d Deploy) (types.Item, error)

Deploy streams d.Body into the blob store and stores the item.

func (*Service) DeployByChecksum

func (s *Service) DeployByChecksum(ctx context.Context, d Deploy) (types.Item, error)

DeployByChecksum stores the item from content the server already holds, found by the strongest declared checksum. Every other declared checksum must match too, and d.Reusable must allow it; otherwise, and when the content is gone, ErrNoBlob.

func (*Service) DeployCommitted

func (s *Service) DeployCommitted(
	ctx context.Context,
	d Deploy,
	info blob.Info,
) (types.Item, error)

DeployCommitted stores the item for content the caller already committed to the blob store, the second half of Deploy. A registry upload commits in a later request than it began, so it cannot hand Deploy a body.

func (*Service) EnsureRoot

func (s *Service) EnsureRoot(ctx context.Context, t Target, by string) (types.Item, error)

EnsureRoot returns the record of the root of t's repository, or of its cache when t.Cached, creating it when absent. The record holds the properties set on the repository itself (store.ItemStore).

func (*Service) Env

func (s *Service) Env() format.Env

Env is the environment of one operation a format offers beside its hooks, such as Maven's calculateMetadata, which reads and queues as a hook does.

func (*Service) Explode

func (s *Service) Explode(ctx context.Context, d Explode) (types.Item, error)

Explode deploys the entries of the archive in d.Body and returns the folder they landed in. The archive is spooled to a temporary file, checked against d.Declared, and read twice: once to validate every entry name and the limits, so nothing is written for an archive that would be refused, then to store the entries.

func (*Service) HasRemoteProperties

func (s *Service) HasRemoteProperties(
	ctx context.Context,
	token types.RemoteCacheToken,
) (bool, error)

HasRemoteProperties applies legacy initial-only synchronization to the item, not each HTTP representation another client may independently request.

func (*Service) Layout

func (s *Service) Layout(ctx context.Context, name string) (*layout.Layout, error)

Layout compiles a repository layout: one the descriptor stored, else a bundled one.

func (*Service) MakeFolder

func (s *Service) MakeFolder(
	ctx context.Context,
	t Target,
	props types.Properties,
	by string,
) (types.Item, error)

MakeFolder creates the folder at t.Path and its parents, once the format admits it (format.FolderAdmitter); an existing folder is returned as it is, with props added.

func (*Service) OwnsSidecars

func (s *Service) OwnsSidecars(c repo.Config) bool

OwnsSidecars reports whether c's format takes every upload named as a checksum sidecar as one, even without its file (format.SidecarOwner).

func (*Service) PropagateRemotePropertyState

func (s *Service) PropagateRemotePropertyState(
	ctx context.Context,
	current types.RemoteCacheEntry,
) error

PropagateRemotePropertyState keeps item-level ownership coherent across a bounded set of current HTTP representations. It joins the caller's item/cache transaction and preserves each representation's separate statistics claims.

func (*Service) Purge

func (s *Service) Purge(ctx context.Context, t Target) (store.DeleteResult, error)

Purge is Delete bypassing the trash can: the references are released at once. It is for an item whose record lives elsewhere, such as a build-info document (decision 0014), which a restore would bring back without its run.

func (*Service) RecordChecksum

func (s *Service) RecordChecksum(
	ctx context.Context,
	t Target,
	a Algorithm,
	value string,
) (types.Item, error)

RecordChecksum is RecordSidecar for a sidecar whose length is unknown.

func (*Service) RecordSidecar

func (s *Service) RecordSidecar(
	ctx context.Context,
	t Target,
	a Algorithm,
	value string,
	size int64,
) (types.Item, error)

RecordSidecar handles a checksum sidecar upload of size bytes (-1 when the client declared none) for the file at t.Path, once the format admits it: the client's value is recorded as the file's original checksum, and under the client-checksums policy it must equal the content's (decision 0004).

func (*Service) RegisterCacheMaintenance

func (s *Service) RegisterCacheMaintenance(ctx context.Context, q *work.Queue) error

RegisterCacheMaintenance registers a periodic scheduler and bounded worker. Existing queued pages survive restart. The scheduler repeats; each repository worker drains pages without waiting another hour between batches.

func (*Service) RegisterWork

func (s *Service) RegisterWork(q *work.Queue) error

RegisterWork registers with q a handler for the reindex kinds every format shares and for every kind of derived work a format runs, each run through s, on a timer for the kinds s.Periodic names. Call it before q.Run, which leases only the kinds registered when it starts.

func (*Service) Reindex

func (s *Service) Reindex(ctx context.Context, c repo.Config) error

Reindex rebuilds c's package index from its item tree through its format; ErrNoReindex when the format keeps none.

func (*Service) ReindexPath

func (s *Service) ReindexPath(ctx context.Context, c repo.Config, path string) error

ReindexPath rebuilds the part of c's package index that the files under path give, through a format that is a PathReindexer, or the whole index through any other Reindexer; ErrNoReindex when the format keeps none.

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, c repo.Config, d format.Download) (string, error)

Resolve returns the path a download d from c, a repository that is not virtual, reads: the format's resolution of it, or d.Path itself. The derived work the format owes that path is done first (EnsureFresh).

func (*Service) Restore

func (s *Service) Restore(
	ctx context.Context,
	t Target,
	rec types.TrashRecord,
	by string,
) (types.Item, error)

Restore recreates a trashed item at t.Path with its recorded content, times and properties, creating missing parent folders, and runs the format's hooks as a deploy does. Call it inside a transaction that also removes the trash entry: a trashed file still holds its blob reference, which the restored item takes over, so no reference is taken here. A file it replaces releases its own reference, as an overwrite by deploy does; a folder already at the path keeps its content and gains the recorded properties. A folder in the way of a file, or a file in the way of a folder, is ErrConflict. Every restored item also carries PropTrashOriginalRepository and PropTrashRestoredTime.

func (*Service) Sidecars

func (s *Service) Sidecars(c repo.Config, p string) []string

Sidecars returns the paths in c of the sidecars that the file at p owns and that c's format keeps with it (format.SidecarKeeper), whether or not any exists; none when the format keeps none.

func (*Service) SidecarsBeside

func (s *Service) SidecarsBeside(ctx context.Context, t Target, to string) ([]SidecarMove, error)

SidecarsBeside returns the stored sidecars that the file at t.Path keeps (format.SidecarKeeper), each with its path beside to, the file's target; to is t.Path for a delete. None for a folder, a path with nothing at it, a format that keeps none, or a target the format gives no such sidecar, which a transfer leaves behind (planFollowers). Those are the paths a delete, copy or move of the file changes besides its own, which a caller must hold the same rights on (decision 0039).

func (*Service) Transfer

func (s *Service) Transfer(ctx context.Context, t Transfer) (TransferResult, error)

Transfer copies or moves t.From to t.To. Every item is planned first: an item that cannot land (a file where a folder must go, or the reverse, an overwrite the caller may not make, or a file the target's format refuses) is reported and skipped with its subtree, or ends the plan when t.FailFast. A file's sidecars that its format keeps with it go with it (format.SidecarKeeper). The planned items are then written in one transaction; a dry run stops after the plan.

func (*Service) Tree

func (s *Service) Tree(ctx context.Context, t Target) ([]types.Item, error)

Tree lists the item at t.Path (none for the repository root) and every item below it, parents before their children.

func (*Service) Upload

func (s *Service) Upload(ctx context.Context, d Deploy) (blob.Info, error)

Upload streams d.Body into the blob store and commits it under the repository's checksum policy, as Deploy does, but stores no item, for a caller that must see the content's digests before deciding what to store: DeployCommitted then stores it. Content no item comes to reference is collected as an orphan.

func (*Service) Zap

func (s *Service) Zap(ctx context.Context, t Target) (int, error)

Zap expires upstream metadata and clears negative state while retaining all complete bytes. Unique and mutable binaries keep their timestamps and cache state. The next normal metadata read refreshes; cache aliases never fetch.

type SidecarError

type SidecarError struct {
	Err     error
	Message string
}

SidecarError is a checksum sidecar upload refused for its file, with Artifactory's answer (UploadServiceImpl.validatePathAndUploadChecksum): Err is store.ErrNotFound for a missing file, ErrConflict for a folder and ErrChecksumMismatch for a value the client-checksums policy refuses.

func (*SidecarError) Error

func (e *SidecarError) Error() string

func (*SidecarError) Unwrap

func (e *SidecarError) Unwrap() error

type SidecarMove

type SidecarMove struct {
	From, To string
}

SidecarMove is a stored sidecar of a file, at From, and the path To beside the file's target where a copy or move of the file takes it.

type Target

type Target struct {
	Repo   repo.Config
	Cached bool
	Path   string
}

Target is where a write lands: a repository (or its remote cache) and a repository-relative path without a leading slash.

type Transfer

type Transfer struct {
	From Target
	To   Target
	// IntoFolder is a target given with a trailing slash: the source lands
	// inside it under its own name, as it does inside an existing folder.
	IntoFolder bool
	Move       bool
	Dry        bool
	FailFast   bool
	// TranslateLayouts converts file paths from the source repository's
	// layout to the target's (suppressLayouts=0).
	TranslateLayouts bool
	// CanOverwrite is the caller's right to replace files at the target.
	CanOverwrite bool
	// IfAbsent requires a new destination file, including when another
	// writer creates it after planning. A collision rolls back the transfer.
	IfAbsent bool
	By       string
}

Transfer is a copy or a move of the item at From.Path (a file, a folder and everything below it, or "" for the whole repository) to To.

type TransferResult

type TransferResult struct {
	Messages []Message
	Files    int
	Folders  int
	Failed   int
}

TransferResult reports a copy or move. Files and Folders count what was (or, in a dry run, would be) transferred; Failed counts the items that were not.

Jump to

Keyboard shortcuts

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