Media roots and resolution¶
Media moves: a production is copied to another workstation, a volume is mounted at a different path, or a folder is reorganized. PostProject keeps asset and representation identity stable while storage locations change, and resolution answers where the content can be reached now.
The relinking flow¶
A host usually relinks when it opens a project whose media has moved. The sections below explain each step; the flow as a whole is:
flowchart TD
open["Host opens its project and reads<br/>the stored asset references"]
open --> resolve["Resolve every asset in one call with this machine's<br/>root map and search directories"]
resolve --> known{"Content at a<br/>known locator?"}
known -- "yes" --> online(["online: use it"])
known -- "no" --> search["Search mapped roots, then search directories:<br/>match names or sequence groups, filter by size,<br/>compare fingerprints"]
search --> found{"Credible<br/>candidates?"}
found -- "none" --> offline(["offline: show as missing,<br/>the identity is kept"])
found -- "one exact" --> exact["resolved exact"]
found -- "one probable" --> probable["resolved probable"]
found -- "several" --> ambiguous["ambiguous"]
exact --> decide{"Host policy<br/>or user decision"}
probable --> decide
ambiguous --> choose["User chooses among the candidates,<br/>shown with confidence and evidence"]
choose --> confirm
decide -- "accept" --> confirm["Confirm the candidate in a transaction:<br/>adds a locator with its root name<br/>and sequence naming"]
decide -- "not now" --> unchanged(["production unchanged"])
confirm --> commit["Commit: a LocatorAdded revision tells<br/>every other application about the new location"]
Resolution itself never changes the production. Only the confirmation step writes, and never on its own for an ambiguous result.
Register a logical media root¶
A media root is a portable, production-wide name such as rushes. It does not
store a machine path. Each machine supplies the local directory for a root name
at resolution time, so the same production resolves correctly on differently
mounted systems.
static pp_error_code_t add_rushes_root(pp_production_t *production,
pp_error_t **error) {
pp_transaction_t *transaction = NULL;
pp_media_root_id_t root_id;
pp_error_code_t status =
pp_production_begin_edit(production, NULL, NULL, &transaction, error);
if (status == PP_OK) {
status = pp_transaction_add_media_root(transaction, "rushes",
"Camera originals", 0, &root_id,
error);
}
if (status == PP_OK) {
pp_commit_receipt_t commit_receipt;
status = pp_transaction_commit(transaction, &commit_receipt, error);
}
pp_transaction_release(transaction);
return status;
}
void add_rushes_root(postproject::Production &production) {
auto transaction = production.edit().value();
transaction.addMediaRoot("rushes", "Camera originals").value();
transaction.commit().value();
}
def add_rushes_root(production: Production) -> None:
with production.edit() as transaction:
transaction.add_media_root("rushes", "Camera originals")
transaction.commit()
fn add_rushes_root(production: &mut SqliteProduction) -> Result<postproject_core::CommitReceipt> {
let root = MediaRoot::new(
MediaRootId::new(),
"rushes",
Some("Camera originals".to_owned()),
None,
0,
true,
)?;
let mut transaction = production.begin_transaction()?;
transaction.add_media_root(root)?;
transaction.commit()
}
postproject root add production.pproj rushes --label "Camera originals"
Roots have an optional label and a priority; lower priorities are searched first.
Disable, enable, and remove roots¶
A disabled root stays in the production but is skipped during resolution, which is useful while a volume is known to be offline. Removing a root deletes the name; locators already confirmed under it keep their recorded root name as history. Each change is a revision like any other:
static pp_error_code_t find_root(const pp_read_session_t *view,
const char *wanted, pp_media_root_id_t *out_root_id,
int *out_found, pp_error_t **error) {
pp_media_root_set_t *roots = NULL;
*out_found = 0;
pp_error_code_t status = pp_read_session_media_roots(view, &roots, error);
/* Roots are ordered by resolver priority, then stable identity. */
for (uint64_t i = 0; status == PP_OK && i < pp_media_root_set_count(roots);
++i) {
pp_media_root_id_t id;
const char *name, *label, *legacy_uri;
int32_t priority = 0;
uint8_t enabled = 0;
status = pp_media_root_set_get(roots, i, &id, &name, &label, &legacy_uri,
&priority, &enabled, error);
if (status == PP_OK) {
printf("root %s (priority %d, %s)\n", name, (int)priority,
enabled ? "enabled" : "disabled");
}
if (status == PP_OK && strcmp(name, wanted) == 0) {
*out_root_id = id;
*out_found = 1;
}
}
pp_media_root_set_release(roots);
return status;
}
static pp_error_code_t apply_root_change(pp_read_session_t *view,
const pp_media_root_id_t *root_id, int change,
pp_error_t **error) {
pp_transaction_t *transaction = NULL;
pp_error_code_t status =
pp_read_session_begin_edit(view, NULL, &transaction, error);
if (status == PP_OK && change == 0) {
/* A disabled root keeps its locators but is skipped by resolution. */
status =
pp_transaction_set_media_root_enabled(transaction, *root_id, 0, error);
} else if (status == PP_OK && change == 1) {
status =
pp_transaction_set_media_root_enabled(transaction, *root_id, 1, error);
} else if (status == PP_OK) {
status = pp_transaction_remove_media_root(transaction, *root_id, error);
}
if (status == PP_OK) {
pp_commit_receipt_t commit_receipt;
status = pp_transaction_commit(transaction, &commit_receipt, error);
}
pp_transaction_release(transaction);
return status;
}
static pp_error_code_t cycle_media_root(pp_production_t *production,
const char *name, pp_error_t **error) {
pp_media_root_id_t root_id;
int found = 0;
pp_error_code_t status = PP_OK;
/* Disable, enable again, then remove: each change is its own revision. */
for (int change = 0; status == PP_OK && change < 3; ++change) {
pp_read_session_t *view = NULL;
status = pp_production_read_session(production, &view, error);
if (status == PP_OK)
status = find_root(view, name, &root_id, &found, error);
if (status == PP_OK && !found) status = PP_ERROR_NOT_FOUND;
if (status == PP_OK)
status = apply_root_change(view, &root_id, change, error);
pp_read_session_release(view);
}
return status;
}
void cycle_media_root(postproject::Production &production,
const std::string &name) {
auto view = production.readSession().value();
std::optional<postproject::MediaRootId> root_id;
for (const auto &root : view.mediaRoots().value()) {
std::cout << "root " << root.name << " priority " << root.priority
<< (root.enabled ? " enabled" : " disabled") << '\n';
if (root.name == name) {
root_id = root.id;
}
}
if (!root_id) {
return;
}
auto disable = view.edit().value();
// A disabled root is kept but skipped during resolution.
disable.setMediaRootEnabled(*root_id, false).value();
disable.commit().value();
auto enable = production.readSession().value().edit().value();
enable.setMediaRootEnabled(*root_id, true).value();
enable.commit().value();
auto remove = production.readSession().value().edit().value();
remove.removeMediaRoot(*root_id).value();
remove.commit().value();
}
def find_root(production: Production, name: str) -> MediaRootId:
for root in production.media_roots: # in priority order
print(f"root {root.name}: enabled={root.enabled} priority={root.priority}")
return next(root.id for root in production.media_roots if root.name == name)
def set_root_enabled(
production: Production, root_id: MediaRootId, enabled: bool
) -> None:
# A disabled root stays configured but is skipped by resolution.
with production.read_session() as view, view.edit() as transaction:
transaction.set_media_root_enabled(root_id, enabled)
transaction.commit()
def remove_root(production: Production, root_id: MediaRootId) -> None:
with production.read_session() as view, view.edit() as transaction:
transaction.remove_media_root(root_id)
transaction.commit()
fn cycle_media_root(
production: &mut SqliteProduction,
name: &str,
) -> Result<postproject_core::CommitReceipt> {
let view = production.read_session()?;
for root in view.read().media_roots()? {
println!("root {} enabled: {}", root.name(), root.is_enabled());
}
let root_id = view
.read()
.media_roots()?
.iter()
.find(|root| root.name() == name)
.map(MediaRoot::id)
.expect("the root is configured");
let base = view.decision_base();
drop(view);
let mut transaction = production.begin_edit(base)?;
// A disabled root stays configured but is skipped during resolution.
transaction.set_media_root_enabled(root_id, false)?;
transaction.commit()?;
drop(transaction);
let base = production.read_session()?.decision_base();
let mut transaction = production.begin_edit(base)?;
transaction.set_media_root_enabled(root_id, true)?;
transaction.remove_media_root(root_id)?;
transaction.commit()
}
postproject root add media.pproj rushes --label "Camera originals"
ARCHIVE_ID=$(postproject --json root add media.pproj archive --priority 10 |
jq -r .id)
postproject root list media.pproj
# A disabled root stays configured but is skipped during resolution.
for ACTION in disable enable remove; do
BASE=$(postproject --json inspect media.pproj | jq -r .decision_base)
postproject --decision-base "$BASE" root "$ACTION" media.pproj "$ARCHIVE_ID"
done
Root creation is additive. Enabling or removing an existing root requires an
edit tied to a read session; CLI commands take its inspect decision token.
Resolve an asset¶
Resolution checks the known locators of every resource and, where content is missing, searches the mapped roots for credible candidates. It reports one aggregate availability per representation (online, partial, offline, ambiguous, or error), the state of each resource, scored candidates with their evidence, and availability issues such as missing sequence frames.
The example maps the rushes root to this machine’s directory after the
imported file has been moved there:
static pp_error_code_t resolve_asset(const pp_production_t *production,
const pp_asset_id_t *asset_id,
const char *rushes_directory,
pp_resolution_set_t **out_resolutions,
pp_error_t **error) {
pp_resolution_options_t *options = NULL;
pp_resolution_set_t *resolutions = NULL;
/* The mapping locates the logical root on this machine for this call only. */
const pp_root_mapping_t mapping = {"rushes", rushes_directory};
pp_resolution_config_t config = PP_RESOLUTION_CONFIG_INIT;
config.root_mappings = &mapping;
config.root_mapping_count = 1;
pp_error_code_t status = pp_resolution_options_create(&config, &options, error);
if (status == PP_OK) {
status = pp_production_resolve_assets(production, asset_id, 1, options,
&resolutions, error);
}
pp_resolution_options_release(options);
const uint64_t count =
status == PP_OK ? pp_resolution_set_representation_count(resolutions) : 0;
for (uint64_t r = 0; status == PP_OK && r < count; ++r) {
pp_asset_id_t resolved_asset_id;
pp_representation_id_t representation_id;
pp_representation_availability_t availability;
uint64_t resource_count = 0;
uint64_t issue_count = 0;
status = pp_resolution_set_get_representation(
resolutions, r, &resolved_asset_id, &representation_id, &availability,
&resource_count, &issue_count, error);
if (status == PP_OK) {
printf("availability: %u\n", availability);
}
for (uint64_t s = 0; status == PP_OK && s < resource_count; ++s) {
pp_resource_id_t resource_id = {0};
pp_resource_resolution_state_t state;
uint64_t candidate_count = 0;
uint64_t evidence_count = 0;
status = pp_resolution_set_get_resource_state(resolutions, r, s, &state, error);
if (status != PP_OK) break;
status = pp_resolution_set_get_resource(resolutions, r, s, state, &resource_id,
&state, &candidate_count,
&evidence_count, error);
for (uint64_t c = 0; status == PP_OK && c < candidate_count; ++c) {
const char *uri = NULL;
uint16_t confidence = 0;
const char *root = NULL;
uint8_t has_naming = 0;
pp_sequence_naming_t naming;
status = pp_resolution_set_get_candidate(
resolutions, r, s, c, &uri, &confidence, &root, &has_naming,
&naming, &evidence_count, error);
if (status == PP_OK) {
printf("candidate: %s (%u/10000) under %s\n", uri, confidence,
root != NULL ? root : "no root");
}
}
}
}
if (status == PP_OK) {
*out_resolutions = resolutions;
} else {
pp_resolution_set_release(resolutions);
}
return status;
}
std::vector<postproject::RepresentationResolution>
resolve_asset(const postproject::Production &production,
const postproject::AssetId &asset_id,
const std::string &rushes_directory) {
// The mapping locates the logical root on this machine for this call only.
postproject::ResolutionConfig config;
config.root_mappings = {{"rushes", rushes_directory}};
config.verification = postproject::VerificationMode::content;
auto options = postproject::ResolutionOptions::create(config).value();
const auto resolutions = production.resolveAsset(asset_id, options).value();
for (const auto &representation : resolutions) {
std::cout << "availability: "
<< static_cast<std::uint32_t>(representation.availability)
<< '\n';
for (const auto &resource : representation.resources) {
for (const auto &candidate : resource.candidates()) {
std::cout << "candidate: " << candidate.uri << " ("
<< candidate.confidence_basis_points << "/10000)\n";
}
}
}
return resolutions;
}
def resolve_asset(
production: Production, asset_id: AssetId, rushes_directory: Path
) -> tuple[RepresentationResolution, ...]:
resolutions = production.resolve(
asset_id, {"rushes": rushes_directory}, verification=VerificationMode.CONTENT
)
for representation in resolutions:
print(f"availability: {representation.availability.name}")
for resource in representation.resources:
for candidate in resource.candidates:
print(
f"candidate: {candidate.uri} "
f"({candidate.confidence_basis_points}/10000)"
)
return resolutions
fn resolve_asset(
production: &SqliteProduction,
asset_id: AssetId,
rushes_directory: &Path,
) -> Result<(
postproject_core::DecisionBase,
Vec<RepresentationResolution>,
)> {
let view = production.read_session()?;
let base = view.decision_base();
let roots = view.read().media_roots()?;
let mut work = Vec::new();
for representation in view.read().representations(asset_id)? {
let resources = view
.read()
.resources(representation.id())?
.into_iter()
.map(|resource| {
let locators = view.read().locators(resource.id())?;
Ok((resource, locators))
})
.collect::<Result<Vec<_>>>()?;
work.push((representation, resources));
}
drop(view); // Release the database view before filesystem work.
let scope = SearchScope::new(
roots,
vec![MediaRootMapping::new("rushes", rushes_directory)?],
);
let items = work
.iter()
.flat_map(|(representation, resources)| {
resources.iter().map(|(resource, locators)| {
ResolutionItem::new(resource, representation.content_structure(), locators)
})
})
.collect::<Vec<_>>();
let resolver = MediaResolver::new(ResolverOptions {
verification: VerificationMode::Content,
..ResolverOptions::default()
})?;
let mut resources = resolver.resolve(&items, &scope)?.into_iter();
let resolutions = work
.iter()
.map(|(representation, members)| {
RepresentationResolution::aggregate(
representation.id(),
representation.content_structure(),
resources.by_ref().take(members.len()).collect(),
)
})
.collect::<Result<Vec<_>>>()?;
Ok((base, resolutions))
}
postproject --json media resolve production.pproj "$ASSET_ID" \
--root-map rushes="$PWD/moved" > resolution.json
jq -r '.resolutions[] | .availability' resolution.json
jq -r '.resolutions[].resources[].candidates[].uri' resolution.json
Resolution is read-only. It never changes locators, even when exactly one candidate matches exactly. An unmapped root is reported as unmapped evidence rather than an error, and an unreadable mapping as unavailable; other roots are still searched.
Confirm a selected representation¶
Keep the representation ID returned by import or the host binding. Select that representation explicitly from the resolution results. A verified selection requires complete required content, unique full fingerprint matches and no failed or truncated search. Presence, sampled matches and a count of one are insufficient. Unverified optional members remain in diagnostics and are omitted.
The selection carries the original coherent database decision and copies each resource’s URI, logical root and sequence naming. Confirm it in an edit using that base, then commit explicitly. Copied selections survive closure of the read view and native result owner. Confirmation stages all locations together; an already recorded resource/URI/naming identity is a guarded no-op.
static pp_error_code_t
confirm_selected_representation(pp_production_t *production,
const pp_resolution_set_t *resolutions,
pp_representation_id_t wanted,
pp_error_t **error) {
const uint64_t count = pp_resolution_set_representation_count(resolutions);
for (uint64_t index = 0; index < count; ++index) {
pp_asset_id_t asset;
pp_representation_id_t representation;
pp_representation_availability_t availability;
uint64_t resources, issues;
pp_error_code_t status = pp_resolution_set_get_representation(resolutions,
index, &asset, &representation, &availability, &resources, &issues, error);
if (status != PP_OK) return status;
if (memcmp(representation.bytes, wanted.bytes, sizeof wanted.bytes) != 0) continue;
if (resources == 0 || resources > 100000) return PP_ERROR_INTERNAL;
pp_relink_location_t *locations = calloc((size_t)resources, sizeof *locations);
if (locations == NULL) return PP_ERROR_INTERNAL;
pp_relink_selection_t selection;
pp_transaction_t *edit = NULL;
status = pp_resolution_set_select_verified(resolutions, index, locations,
resources, &selection, error);
if (status == PP_OK) status = pp_production_begin_edit(production,
&selection.base, NULL, &edit, error);
if (status == PP_OK) status = pp_transaction_confirm_selection(edit, &selection, error);
if (status == PP_OK) {
pp_commit_receipt_t receipt;
status = pp_transaction_commit(edit, &receipt, error);
}
pp_transaction_release(edit);
free(locations);
return status;
}
return PP_ERROR_NOT_FOUND;
}
void confirm_selected_representation(
postproject::Production &production,
const std::vector<postproject::RepresentationResolution> &resolutions,
const postproject::RepresentationId &representation_id) {
const auto found = std::find_if(resolutions.begin(), resolutions.end(),
[&](const auto &value) { return value.representation_id == representation_id; });
require(found != resolutions.end(), "selected representation was not resolved");
const auto selection = found->selectVerified().value();
auto edit = production.edit(selection.base).value();
edit.confirmSelection(selection).value();
edit.commit().value();
}
def confirm_selected_representation(
production: Production,
resolutions: tuple[RepresentationResolution, ...],
representation_id: RepresentationId,
) -> None:
# Use the identity retained by the host; never take an arbitrary first result.
resolution = next(
item for item in resolutions if item.representation_id == representation_id
)
selection = resolution.select_verified()
with production.edit(base=selection.base) as edit:
edit.confirm_selection(selection)
edit.commit()
fn confirm_selected_representation(
production: &mut SqliteProduction,
base: postproject_core::DecisionBase,
resolutions: &[RepresentationResolution],
representation_id: RepresentationId,
) -> Result<postproject_core::CommitReceipt> {
let resolution = resolutions
.iter()
.find(|item| item.representation_id() == representation_id)
.ok_or_else(|| {
Error::new(
ErrorKind::NotFound,
"selected representation was not resolved",
)
})?;
let selection = resolution.select_verified(base)?;
stage_relink(production, &selection)?.commit()
}
# Name the host's retained representation and explicitly confirm verified content.
# Ambiguous, unverified and incomplete searches fail without changing locators.
postproject media relink production.pproj "$ORIGINAL_ID" \
--root-map rushes="$PWD/moved" --confirm
Selection performs no additional scan. Confirmation does not recheck media files or guarantee filesystem atomicity. Hosts still check that their object, association and generation match the result before applying it.
For a human-selected ambiguous candidate, or content verified by a host’s own
hash algorithm, use explicit locator confirmation after reviewing the evidence.
Pass the candidate’s root and sequence naming; retain the original decision
base. Host content hashes
explains fingerprint_not_verified. Logical roots describe production knowledge;
local mount mappings are not persisted.
Relink a renamed image sequence¶
Graded plates get a suffix, renders are renamed for delivery, and conform
tools rename by shot. A sequence’s file names belong to its locator, not to its
content (ADR 0038), so resolution finds a renamed sequence by content. It
groups the numbered files of each searched directory by prefix, suffix, and
padding. A group that holds every expected frame and matches the sequence’s
sampled fingerprint is a candidate carrying the naming it was found under, with
partial_fingerprint_match evidence. file_name_match evidence is added only
when that naming is one already recorded for the resource. A group with other
content, or with frames missing, is not a candidate, and two matching copies
are ambiguous.
Confirming the candidate with its naming records a second locator. The original locator keeps the original names, so a backup under the old names stays a valid place of the same sequence:
static pp_error_code_t relink_renamed_sequence(pp_production_t *production,
const pp_asset_id_t *asset_id,
const char *directory,
int *out_relinked,
pp_error_t **error) {
pp_resolution_options_t *options = NULL;
pp_resolution_set_t *resolutions = NULL;
pp_transaction_t *transaction = NULL;
*out_relinked = 0;
pp_resolution_config_t config = PP_RESOLUTION_CONFIG_INIT;
config.search_directories = &directory;
config.search_directory_count = 1;
pp_error_code_t status = pp_resolution_options_create(&config, &options, error);
if (status == PP_OK) {
status = pp_production_resolve_assets(production, asset_id, 1, options,
&resolutions, error);
}
if (status == PP_OK) {
status = pp_production_begin_edit(production, NULL, NULL, &transaction, error);
}
const uint64_t count =
status == PP_OK ? pp_resolution_set_representation_count(resolutions) : 0;
for (uint64_t r = 0; status == PP_OK && r < count; ++r) {
pp_asset_id_t owner;
pp_representation_id_t representation_id;
pp_representation_availability_t availability;
uint64_t resource_count = 0, issue_count = 0;
status = pp_resolution_set_get_representation(
resolutions, r, &owner, &representation_id, &availability,
&resource_count, &issue_count, error);
for (uint64_t s = 0; status == PP_OK && s < resource_count; ++s) {
pp_resource_id_t resource_id;
pp_resource_resolution_state_t state;
uint64_t candidate_count = 0, evidence_count = 0;
status = pp_resolution_set_get_resource_state(resolutions, r, s, &state, error);
if (status != PP_OK) break;
status = pp_resolution_set_get_resource(resolutions, r, s, state, &resource_id,
&state, &candidate_count,
&evidence_count, error);
if (status != PP_OK || candidate_count != 1) {
continue;
}
/* A renamed sequence is found by content; the candidate carries the
* naming its files have now. */
const char *uri = NULL, *root = NULL;
uint16_t confidence = 0;
uint8_t has_naming = 0;
pp_sequence_naming_t naming;
status = pp_resolution_set_get_candidate(
resolutions, r, s, 0, &uri, &confidence, &root, &has_naming, &naming,
&evidence_count, error);
if (status != PP_OK || !has_naming) {
continue;
}
printf("%s as %s%%0%ud%s\n", uri, naming.prefix, (unsigned)naming.padding,
naming.suffix);
status = pp_transaction_confirm_locator(transaction, resource_id, uri,
root, &naming, error);
*out_relinked += status == PP_OK;
}
}
if (status == PP_OK) {
pp_commit_receipt_t commit_receipt;
status = pp_transaction_commit(transaction, &commit_receipt, error);
}
pp_transaction_release(transaction);
pp_resolution_set_release(resolutions);
pp_resolution_options_release(options);
return status;
}
std::optional<postproject::SequenceNaming>
relink_renamed_sequence(postproject::Production &production,
const postproject::AssetId &asset_id,
const std::string &directory) {
postproject::ResolutionConfig config;
config.search_directories = {directory};
auto options = postproject::ResolutionOptions::create(config).value();
for (const auto &representation :
production.resolveAsset(asset_id, options).value()) {
for (const auto &resource : representation.resources) {
// A renamed sequence is found by content; the candidate carries the
// naming its files have now.
if (resource.candidates().size() != 1 ||
!resource.candidates().front().sequence_naming.has_value()) {
continue;
}
const auto &candidate = resource.candidates().front();
for (const auto &evidence : candidate.evidence) {
std::cout << candidate.uri << " evidence "
<< static_cast<unsigned>(evidence.kind) << '\n';
}
auto transaction = production.edit().value();
transaction
.confirmLocator(resource.resource_id, candidate.uri,
candidate.media_root, candidate.sequence_naming)
.value();
transaction.commit().value();
return candidate.sequence_naming;
}
}
return std::nullopt;
}
def relink_renamed_sequence(
production: Production, asset_id: AssetId, directory: Path
) -> SequenceNaming | None:
for representation in production.resolve(asset_id, search_directories=[directory]):
for resource in representation.resources:
# A renamed sequence is found by content; the candidate carries the
# naming its files have now.
if len(resource.candidates) != 1:
continue
candidate = resource.candidates[0]
if candidate.sequence_naming is None:
continue
for evidence in candidate.evidence:
print(f"{candidate.uri}: {evidence.kind.name}")
with production.edit() as transaction:
transaction.confirm_locator(
resource.resource_id,
candidate.uri,
media_root=candidate.media_root,
sequence_naming=candidate.sequence_naming,
)
transaction.commit()
return candidate.sequence_naming
return None
fn relink_renamed_sequence(
production: &mut SqliteProduction,
asset_id: AssetId,
directory: &Path,
) -> Result<Option<SequenceNaming>> {
let mut inputs = Vec::new();
for representation in production.representations(asset_id)? {
for resource in production.resources(representation.id())? {
let locators = production.locators(resource.id())?;
inputs.push((representation.clone(), resource, locators));
}
}
let items = inputs
.iter()
.map(|(representation, resource, locators)| {
ResolutionItem::new(resource, representation.content_structure(), locators)
})
.collect::<Vec<_>>();
let scope = SearchScope::default().with_search_directory(directory);
for resolution in MediaResolver::default().resolve(&items, &scope)? {
// A renamed sequence is found by content; the candidate carries the
// naming its files have now.
let [candidate] = resolution.candidates() else {
continue;
};
let Some(naming) = candidate.sequence_naming() else {
continue;
};
for evidence in candidate.evidence() {
println!("{} {:?}", candidate.uri(), evidence.kind());
}
let locator = prepare_confirmed_locator(
resolution.resource_id(),
candidate.uri(),
candidate.media_root(),
Some(naming.clone()),
)?;
let mut transaction = production.begin_transaction()?;
transaction.add_locator(&locator)?;
transaction.commit()?;
return Ok(Some(naming.clone()));
}
Ok(None)
}
# A renamed sequence is found by content; each candidate carries the naming
# its files have now, as a printf-style pattern.
postproject --json media resolve media.pproj "$STRIP_ID" --search-dir "$PWD/graded" |
jq -r '.resolutions[].resources[].candidates[] |
"\(.uri) \(.sequence_naming.pattern) \([.evidence[].kind])"'
# Confirmation records the candidate with its naming; --confirm-naming picks
# one when several namings were found in the same directory.
postproject media resolve media.pproj "$STRIP_ID" --search-dir "$PWD/graded" \
--confirm "$(postproject --json media resolve media.pproj "$STRIP_ID" \
--search-dir "$PWD/graded" |
jq -r '.resolutions[0].resources[0].candidates[0].uri')" \
--confirm-naming 'shot010-graded_%04d.exr'
A sequence imported before schema 15 has only a version 1 sequence fingerprint,
which included file names and is no longer computed. Until its content is
observed again, a moved sequence is offered only under a recorded naming, with
fingerprint_not_verified evidence rather than a fingerprint match.
Search near where media was¶
Named roots describe storage shared across machines. Many hosts, such as editors, compositors, and scripts, know only a project folder and absolute paths. They search search directories instead of inventing roots:
Where to search. A search directory is an unnamed, machine-local directory, for example the project folder or a clip’s former folder. It is searched after the mapped roots and is never recorded in the production.
What a candidate carries. A candidate found only there has no root, so it is confirmed as a plain locator.
Never put machine paths in root names or labels. Doing so leaks one workstation’s layout into every copy of the production.
static pp_error_code_t find_nearby(const pp_production_t *production,
const pp_asset_id_t *asset_ids,
uint64_t asset_count, const char *directory,
const pp_cancel_token_t *cancel_token,
char *out_uri, size_t out_uri_size,
pp_error_t **error) {
pp_resolution_options_t *options = NULL;
pp_resolution_set_t *resolutions = NULL;
/* A search directory is an unnamed, machine-local place such as the
* project folder or where the media used to be; it is never recorded. */
pp_resolution_config_t config = PP_RESOLUTION_CONFIG_INIT;
config.search_directories = &directory;
config.search_directory_count = 1;
config.max_depth = 16;
config.max_entries_per_directory = 50000;
config.cancel_token = cancel_token;
/* Another thread may cancel the token. Each search directory has its own
* budget; a partial search reports PP_EVIDENCE_SEARCH_TRUNCATED. */
pp_error_code_t status = pp_resolution_options_create(&config, &options, error);
if (status == PP_OK) {
/* All assets are resolved together; each directory is scanned once. */
status = pp_production_resolve_assets(production, asset_ids, asset_count,
options, &resolutions, error);
}
pp_resolution_options_release(options);
out_uri[0] = '\0';
const uint64_t count =
status == PP_OK ? pp_resolution_set_representation_count(resolutions) : 0;
for (uint64_t r = 0; status == PP_OK && r < count; ++r) {
pp_asset_id_t asset_id;
pp_representation_id_t representation_id;
pp_representation_availability_t availability;
uint64_t resource_count = 0, issue_count = 0;
status = pp_resolution_set_get_representation(
resolutions, r, &asset_id, &representation_id, &availability,
&resource_count, &issue_count, error);
for (uint64_t s = 0; status == PP_OK && s < resource_count; ++s) {
pp_resource_id_t resource_id;
pp_resource_resolution_state_t state;
uint64_t candidate_count = 0, evidence_count = 0;
status = pp_resolution_set_get_resource_state(resolutions, r, s, &state, error);
if (status != PP_OK) break;
status = pp_resolution_set_get_resource(resolutions, r, s, state, &resource_id,
&state, &candidate_count,
&evidence_count, error);
const char *uri = NULL;
const char *root = NULL;
uint16_t confidence = 0;
uint8_t has_naming = 0;
pp_sequence_naming_t naming;
if (status == PP_OK && candidate_count == 1) {
status = pp_resolution_set_get_candidate(
resolutions, r, s, 0, &uri, &confidence, &root, &has_naming,
&naming, &evidence_count, error);
}
for (uint64_t e = 0; status == PP_OK && uri != NULL && e < evidence_count;
++e) {
pp_evidence_kind_t kind;
const char *detail = NULL;
status = pp_resolution_set_get_candidate_evidence(
resolutions, r, s, 0, e, &kind, &detail, error);
if (status == PP_OK) {
printf("%s evidence %u: %s\n", uri, kind,
detail != NULL ? detail : "-");
}
}
/* Only discovered candidates need confirmation; one found in a search
* directory has no root (root == NULL). */
const int discovered = state == PP_RESOURCE_RESOLVED_EXACT ||
state == PP_RESOURCE_RESOLVED_PROBABLE;
if (status == PP_OK && discovered && uri != NULL && out_uri[0] == '\0' &&
root == NULL) {
snprintf(out_uri, out_uri_size, "%s", uri);
}
}
}
pp_resolution_set_release(resolutions);
return status;
}
postproject::Result<std::optional<std::string>>
find_nearby(const postproject::Production &production,
const std::vector<postproject::AssetId> &asset_ids,
const std::string &directory,
const postproject::CancelToken &cancel_token) {
// A search directory is an unnamed, machine-local place such as the project
// folder or where the media used to be; it is never recorded. Each searched
// directory has its own budget, and another thread may cancel the token.
postproject::ResolutionConfig config;
config.search_directories = {directory};
config.max_depth = 16;
config.max_entries_per_directory = 50000;
config.cancel_token = &cancel_token;
POSTPROJECT_TRY_ASSIGN(auto options, postproject::ResolutionOptions::create(config));
// All assets are resolved together; each directory is scanned once. A
// cancelled token yields ErrorCode::cancelled.
POSTPROJECT_TRY_ASSIGN(const auto resolutions,
production.resolveAssets(asset_ids, options));
for (const auto &representation : resolutions) {
for (const auto &resource : representation.resources) {
const bool discovered =
resource.state() == postproject::ResourceResolutionState::resolved_exact ||
resource.state() ==
postproject::ResourceResolutionState::resolved_probable;
// A candidate from a search directory has no media root.
if (discovered && resource.candidates().size() == 1 &&
!resource.candidates().front().media_root.has_value()) {
return std::optional<std::string>(resource.candidates().front().uri);
}
}
}
return std::optional<std::string>();
}
def find_nearby(
production: Production,
asset_ids: list[AssetId],
directory: Path,
cancel_token: CancelToken,
) -> str | None:
# A search directory is an unnamed, machine-local place such as the project
# folder or where the media used to be; it is never recorded. Each searched
# directory has its own budget, and another thread may cancel the token.
# All assets are resolved together; each directory is scanned once.
for representation in production.resolve(
asset_ids,
search_directories=[directory],
verification=VerificationMode.PRESENCE,
max_depth=16,
max_entries_per_directory=50_000,
cancel_token=cancel_token,
):
for resource in representation.resources:
discovered = resource.state in (
ResourceResolutionState.RESOLVED_EXACT,
ResourceResolutionState.RESOLVED_PROBABLE,
)
# A candidate from a search directory has no media root.
if discovered and len(resource.candidates) == 1:
(candidate,) = resource.candidates
if candidate.media_root is None:
return candidate.uri
return None
fn find_nearby(
production: &SqliteProduction,
asset_ids: &[AssetId],
directory: &Path,
cancellation: CancellationToken,
) -> Result<Option<String>> {
// A search directory is an unnamed, machine-local place such as the project
// folder or where the media used to be; it is never recorded. Each searched
// directory has its own budget, and another thread may cancel the token.
let resolver = MediaResolver::new(ResolverOptions {
max_depth: 16,
max_entries_per_directory: 50_000,
verification: VerificationMode::Presence,
cancellation: Some(cancellation),
})?;
let mut inputs = Vec::new();
for asset_id in asset_ids {
for representation in production.representations(*asset_id)? {
for resource in production.resources(representation.id())? {
let locators = production.locators(resource.id())?;
inputs.push((representation.clone(), resource, locators));
}
}
}
let items = inputs
.iter()
.map(|(representation, resource, locators)| {
ResolutionItem::new(resource, representation.content_structure(), locators)
})
.collect::<Vec<_>>();
let scope = SearchScope::default().with_search_directory(directory);
// All resources are resolved together; each directory is scanned once.
for resolution in resolver.resolve(&items, &scope)? {
let discovered = matches!(
resolution.state(),
ResourceResolutionState::ResolvedExact | ResourceResolutionState::ResolvedProbable
);
// A candidate from a search directory has no media root.
if let [candidate] = resolution.candidates() {
if discovered && candidate.media_root().is_none() {
return Ok(Some(candidate.uri().to_owned()));
}
}
}
Ok(None)
}
# A search directory is an unnamed, machine-local place, such as where the
# media used to be; it is searched after mapped roots and never recorded.
postproject --json media resolve media.pproj "$ASSET_ID" \
--search-dir "$PWD/moved" |
jq -r '.resolutions[].resources[] | select(.state == "resolved_exact") |
.candidates[0] | "\(.uri) (root: \(.media_root // "-"))"'
Resolve everything that is offline in one call. When a host opens a project, it passes every asset to resolution at once. PostProject then walks each root and search directory a single time and shares that scan across all resources. Resolving assets one by one repeats the scan for each of them.
Each searched directory has its own entry budget. A directory with more
entries than its budget is searched partially and reported with
search_truncated evidence. The other directories, and the candidates already
found, are still used.
Cancel from another thread. Pass a cancellation token when the host resolves from a user interface, and cancel it from any thread to stop a long scan. The call then fails with a cancelled error, and nothing has changed, because resolution is read-only.
Compare locators with host paths¶
A locator is a URI, and several spellings of a URI can name the same file. Each
URL library chooses its own percent-encoding, case, and treatment of symbolic
links. Qt’s QUrl, Foundation’s NSURL, Python’s pathlib, and Rust’s url
crate can therefore produce different strings for one path. Never compare a URI
you built yourself with a locator from the production. Instead:
Ask PostProject for the locator of a path. It is exactly what import and confirmation record, and it can be compared as a plain string.
Convert a recorded locator back to a native path when the host needs to open the file.
static pp_error_code_t is_recorded_locator(const char *path,
const char *recorded_uri,
int *out_same, pp_error_t **error) {
/* Spell the path as PostProject spells locators instead of building a URI
* with the host's own URL type, then compare the strings exactly. */
char *uri = NULL;
char *native_path = NULL;
pp_error_code_t status = pp_file_path_to_locator(path, &uri, error);
if (status == PP_OK) {
*out_same = strcmp(uri, recorded_uri) == 0;
status = pp_locator_to_file_path(recorded_uri, &native_path, error);
}
if (status == PP_OK) {
printf("recorded locator %s is %s\n", recorded_uri, native_path);
}
pp_string_release(native_path);
pp_string_release(uri);
return status;
}
bool is_recorded_locator(const std::string &path,
const std::string &recorded_uri) {
// Spell the path as PostProject spells locators instead of building a URI
// with the host's own URL type, then compare the strings exactly.
std::cout << "recorded locator " << recorded_uri << " is "
<< postproject::locatorFilePath(recorded_uri).value() << '\n';
return postproject::fileLocator(path).value() == recorded_uri;
}
def is_recorded_locator(path: Path, recorded_uri: str) -> bool:
# Spell the path as PostProject spells locators instead of building a URI
# with pathlib or urllib, then compare the strings exactly.
print(f"recorded locator {recorded_uri} is {locator_file_path(recorded_uri)}")
return file_locator(path) == recorded_uri
fn is_recorded_locator(path: &Path, recorded_uri: &str) -> Result<bool> {
// Spell the path as PostProject spells locators instead of building a URI
// by hand, then compare the strings exactly.
println!(
"recorded locator {recorded_uri} is {}",
local_file_path(recorded_uri)?.display()
);
Ok(canonical_file_uri(path)? == recorded_uri)
}
The CLI prints recorded locators with postproject locator list, and records
the locators of paths you pass it, but has no separate conversion command.
Resolving a path’s locator also resolves symbolic links and relative components, so the path must exist. The reverse conversion does not touch the filesystem.
Read availability issues¶
A representation can be partially available: a sequence with missing frames, a package with a missing optional sidecar, a span with one unreadable part. Each issue names the resource and whether it is required; missing sequence frames are reported as sorted frame numbers. Every resource result also carries the evidence behind its state, so a host can explain why it is offline or ambiguous:
static pp_error_code_t
print_resolution_issues(const pp_production_t *production,
const pp_asset_id_t *asset_id, int64_t *out_missing_frame,
uint64_t *out_evidence_count, pp_error_t **error) {
pp_resolution_set_t *resolutions = NULL;
/* Resolution is read-only; it never changes the production. */
pp_error_code_t status = pp_production_resolve_assets(
production, asset_id, 1, NULL, &resolutions, error);
const uint64_t count =
status == PP_OK ? pp_resolution_set_representation_count(resolutions) : 0;
for (uint64_t r = 0; status == PP_OK && r < count; ++r) {
pp_asset_id_t resolved_asset_id;
pp_representation_id_t representation_id;
pp_representation_availability_t availability;
uint64_t resource_count = 0;
uint64_t issue_count = 0;
status = pp_resolution_set_get_representation(
resolutions, r, &resolved_asset_id, &representation_id, &availability,
&resource_count, &issue_count, error);
for (uint64_t i = 0; status == PP_OK && i < issue_count; ++i) {
pp_resource_id_t resource_id;
uint8_t required = 0;
pp_availability_issue_kind_t kind;
uint64_t frame_count = 0;
status =
pp_resolution_set_get_issue(resolutions, r, i, &resource_id,
&required, &kind, &frame_count, error);
if (status == PP_OK) {
printf("issue kind %u (%s)\n", kind,
required ? "required" : "optional");
}
/* Missing frames are sorted individual frame numbers. */
for (uint64_t f = 0; status == PP_OK && f < frame_count; ++f) {
status = pp_resolution_set_get_issue_frame(resolutions, r, i, f,
out_missing_frame, error);
if (status == PP_OK) {
printf(" missing frame %lld\n", (long long)*out_missing_frame);
}
}
}
for (uint64_t s = 0; status == PP_OK && s < resource_count; ++s) {
pp_resource_id_t resource_id;
pp_resource_resolution_state_t state;
uint64_t candidate_count = 0;
uint64_t evidence_count = 0;
status = pp_resolution_set_get_resource_state(resolutions, r, s, &state, error);
if (status != PP_OK) break;
status = pp_resolution_set_get_resource(resolutions, r, s, state, &resource_id,
&state, &candidate_count,
&evidence_count, error);
for (uint64_t e = 0; status == PP_OK && e < evidence_count; ++e) {
pp_evidence_kind_t kind;
const char *detail = NULL;
status = pp_resolution_set_get_resource_evidence(resolutions, r, s, e,
&kind, &detail, error);
if (status == PP_OK) {
printf(" resource %llu (state %u) evidence %u: %s\n",
(unsigned long long)s, state, kind,
detail != NULL ? detail : "-");
++*out_evidence_count;
}
}
}
}
pp_resolution_set_release(resolutions);
return status;
}
std::vector<postproject::AvailabilityIssue>
report_issues(const postproject::Production &production,
const postproject::AssetId &asset_id) {
std::vector<postproject::AvailabilityIssue> all;
for (const auto &representation : production.resolveAsset(asset_id).value()) {
for (const auto &issue : representation.issues) {
std::cout << "issue " << static_cast<std::uint32_t>(issue.kind())
<< (issue.required ? " (required)" : "") << ", frames:";
if (const auto *missing = std::get_if<postproject::MissingSequenceFrames>(&issue.detail.value())) {
for (const auto frame : missing->frames) std::cout << ' ' << frame;
}
std::cout << '\n';
all.push_back(issue);
}
for (const auto &resource : representation.resources) {
std::cout << " resource state "
<< static_cast<std::uint32_t>(resource.state()) << '\n';
for (const auto &evidence : resource.evidence) {
std::cout << " evidence " << static_cast<std::uint32_t>(evidence.kind)
<< ": " << evidence.detail.value_or("-") << '\n';
}
}
}
return all;
}
def report_availability_issues(
production: Production, asset_id: AssetId
) -> list[AvailabilityIssue]:
issues: list[AvailabilityIssue] = []
for representation in production.resolve(asset_id):
print(f"{representation.representation_id}: {representation.availability.name}")
for issue in representation.issues:
print(f" issue {issue.kind.name}")
if isinstance(issue.detail, MissingSequenceFrames):
print(f" missing frames={list(issue.detail.frames)}")
issues.append(issue)
for resource in representation.resources:
for evidence in resource.evidence:
print(
f" {resource.resource_id} {resource.state.name}: "
f"{evidence.kind.name} {evidence.detail or ''}"
)
return issues
fn print_resolution_issues(
production: &SqliteProduction,
asset_id: AssetId,
) -> Result<Vec<RepresentationResolution>> {
let resolver = MediaResolver::default();
let roots = production.media_roots()?;
let mut resolutions = Vec::new();
for representation in production.representations(asset_id)? {
let structure = representation.content_structure();
let mut resources = Vec::new();
for resource in production.resources(representation.id())? {
let locators = production.locators(resource.id())?;
resources.push(resolver.resolve_resource(
&resource,
structure,
&locators,
&roots,
&[],
)?);
}
let resolution =
RepresentationResolution::aggregate(representation.id(), structure, resources)?;
println!("{}: {:?}", representation.id(), resolution.availability());
for issue in resolution.issues() {
println!(
" {:?} on {} (required: {}), frames {:?}",
issue.kind(),
issue.resource_id(),
issue.is_required(),
issue.frames()
);
}
for resource in resolution.resources() {
println!(
" resource {}: {:?}",
resource.resource_id(),
resource.state()
);
// Resource-level evidence explains a failed search, such as an unmapped root.
for evidence in resource.evidence() {
println!(" {:?} {:?}", evidence.kind(), evidence.detail());
}
for candidate in resource.candidates() {
for evidence in candidate.evidence() {
println!(" {}: {:?}", candidate.uri(), evidence.kind());
}
}
}
resolutions.push(resolution);
}
Ok(resolutions)
}
postproject --json media resolve media.pproj "$ASSET_ID" \
--root-map rushes="$PWD/moved" > resolution.json
jq -r '.resolutions[] | .representation_id as $rep | .issues[] |
"\($rep) \(.kind) required=\(.required) frames=\(.frames)"' resolution.json
jq -r '.resolutions[].resources[] |
"\(.resource_id) \(.state) \([.evidence[].kind, .candidates[].evidence[].kind])"' \
resolution.json
Retire a superseded locator¶
Confirming a new location adds a locator; it does not delete the old one. When an old access route is known to be useless — a decommissioned volume, a renamed share — retire it explicitly. The resource and its identity are unaffected:
static pp_error_code_t retire_superseded(pp_production_t *production,
const pp_resource_id_t *resource_id,
pp_locator_id_t old_locator_id,
uint64_t *out_remaining,
pp_error_t **error) {
/* Persisted UUID text is parsed into its semantic type at interchange. */
char *saved_id = NULL;
pp_locator_id_t parsed_id;
pp_error_code_t status = pp_locator_id_format(old_locator_id, &saved_id, error);
if (status == PP_OK) status = pp_locator_id_parse(saved_id, &parsed_id, error);
pp_string_release(saved_id);
if (status != PP_OK) return status;
if (memcmp(parsed_id.bytes, old_locator_id.bytes, 16)) return PP_ERROR_INTERNAL;
pp_transaction_t *transaction = NULL;
pp_read_session_t *view = NULL;
status = pp_production_read_session(production, &view, error);
if (status == PP_OK)
status = pp_read_session_begin_edit(view, NULL, &transaction, error);
pp_read_session_release(view);
if (status == PP_OK) {
/* Retire only a locator already superseded by a confirmed one. */
status = pp_transaction_retire_locator(transaction, old_locator_id, error);
}
if (status == PP_OK) {
pp_commit_receipt_t commit_receipt;
status = pp_transaction_commit(transaction, &commit_receipt, error);
}
pp_transaction_release(transaction);
char cursor_storage[2049] = {0};
const char *cursor = NULL;
*out_remaining = 0;
while (status == PP_OK) {
pp_locator_query_set_t *page = NULL;
status = pp_production_locators_page(production, *resource_id, UINT32_C(1),
cursor, &page, error);
for (uint64_t i = 0;
status == PP_OK && i < pp_locator_query_set_count(page); ++i) {
pp_locator_id_t locator_id;
pp_resource_id_t owner_id;
const char *uri, *media_root;
pp_locator_availability_t availability;
uint8_t has_last_seen = 0, has_naming = 0;
int64_t last_seen = 0;
pp_sequence_naming_t naming;
status = pp_locator_query_set_get(
page, i, &locator_id, &owner_id, &uri, &availability, &has_last_seen,
&last_seen, &media_root, &has_naming, &naming, error);
if (status == PP_OK) {
printf("current locator: %s\n", uri);
++*out_remaining;
}
}
const char *next =
status == PP_OK ? pp_locator_query_set_next_cursor(page) : NULL;
const int copied =
next != NULL
? snprintf(cursor_storage, sizeof cursor_storage, "%s", next)
: 0;
pp_locator_query_set_release(page);
if (status != PP_OK || copied == 0) {
break;
}
if (copied < 0 || (size_t)copied >= sizeof cursor_storage) {
status = PP_ERROR_INTERNAL;
}
cursor = cursor_storage;
}
return status;
}
std::vector<postproject::ResourceLocator> move_resource(
postproject::Production &production, const postproject::ResourceId &resource_id,
const postproject::LocatorId &old_locator_id, const std::string &new_uri) {
const auto resource_text = resource_id.toString().value();
require(postproject::ResourceId::fromString(resource_text).value() == resource_id &&
postproject::ObjectRef::resource(resource_id).resourceId().value() == resource_id,
"saved resource identity and checked target");
// Saved locator text preserves identity through an explicit parse boundary.
const auto saved = old_locator_id.toString().value();
require(postproject::LocatorId::fromString(saved).value() == old_locator_id,
"saved locator identity");
auto transaction = production.readSession().value().edit().value();
transaction.confirmLocator(resource_id, new_uri).value();
// Retiring keeps the old locator as history instead of deleting it.
transaction.retireLocator(old_locator_id).value();
transaction.commit().value();
std::vector<postproject::ResourceLocator> locators;
std::optional<std::string> cursor;
do {
const auto page = production.locators(resource_id, 1, cursor).value();
locators.insert(locators.end(), page.items.begin(), page.items.end());
cursor = page.next_cursor;
} while (cursor.has_value());
return locators;
}
def retire_superseded_locator(
production: Production, resource_id: ResourceId, superseded_uri: str
) -> list[LocatorMatch]:
with production.read_session() as view, view.edit() as transaction:
for match in view.locators_page(resource_id, limit=100).items:
if match.locator.uri == superseded_uri:
transaction.retire_locator(match.locator.id)
transaction.commit()
remaining: list[LocatorMatch] = []
cursor = None
while True:
page = production.locators_page(resource_id, limit=100, cursor=cursor)
remaining.extend(page.items)
cursor = page.next_cursor
if cursor is None:
return remaining
fn move_to_archive(
production: &mut SqliteProduction,
resource_id: ResourceId,
archived: &Path,
) -> Result<()> {
let view = production.read_session()?;
let superseded: Vec<_> = view.read().locators(resource_id)?;
let base = view.decision_base();
drop(view);
let replacement =
prepare_confirmed_locator(resource_id, canonical_file_uri(archived)?, None, None)?;
{
let mut transaction = production.begin_edit(base)?;
transaction.add_locator(&replacement)?;
for locator in &superseded {
transaction.retire_locator(locator.id())?;
}
transaction.commit()?;
}
let mut cursor = None;
loop {
let page = production.locators_page(resource_id, &QueryPageRequest::new(100, cursor)?)?;
for locator in page.items() {
println!("{} ({:?})", locator.uri(), locator.availability());
}
cursor = page.next_cursor().cloned();
if cursor.is_none() {
return Ok(());
}
}
}
# The file moved and its new location was confirmed; retire the old route.
BASE=$(postproject --json inspect media.pproj | jq -r .decision_base)
postproject --decision-base "$BASE" locator retire media.pproj "$OLD_LOCATOR_ID"
CURSOR=
while :; do
ARGS=(--json locator list media.pproj "$RESOURCE_ID" --limit 100)
[[ -n "$CURSOR" ]] && ARGS+=(--cursor "$CURSOR")
PAGE=$(postproject "${ARGS[@]}")
jq -r '.items[] | "\(.uri) (root: \(.media_root // "-"))"' <<<"$PAGE"
CURSOR=$(jq -r '.next_cursor // empty' <<<"$PAGE")
[[ -z "$CURSOR" ]] && break
done
Retiring a resource’s only locator makes its representation show up in the knowledge-only unresolved-media query until a new location is confirmed.
Python resource results expose outcome, a frozen case such as
ResourceResolvedExact, ResourceAmbiguous or ResourceOffline.
Use isinstance to inspect the applicable payload. state and candidates
are derived properties; an ambiguous result always contains at least two
candidates. Candidate evidence is copied into owned tuples.
C++ uses resource.outcome.value() with std::get_if for case inspection.
resource.state() and resource.candidates() borrow from the checked outcome;
these candidate references last while the owning result is unchanged.
Resolution depth is 1..64. A combined request, discovery index or retained
result exceeding 100000 items or 64 MiB returns Unsupported; reduce the
resource or search scope. Returned candidates are ordered deterministically,
while a truncated directory search covers only part of its entries.