remount method
Re-establishes mountId after a node restart or fresh CLI run: git mounts
re-clone (the node reuses an existing checkout), directory mounts re-anchor
on the node and push the local copy back up.
Implementation
Future<MountRecord> remount(
String mountId, {
DriveProgress? onProgress,
}) async {
final record = require(mountId);
final updated = await _withSession(record, (rpc) async {
if (record.isGit) {
_emit(
onProgress,
ProgressPhase.transferring,
'cloning ${record.gitUrl}',
);
final head = await rpc.gitClone(
record.gitUrl!,
branch: record.gitBranch,
);
_emit(onProgress, ProgressPhase.done, 'cloned');
return record.copyWith(
syncState: SyncState(
baselineRef: SyncRef.git(head),
currentRef: SyncRef.git(head),
status: SyncStatus.clean,
lastSyncedAt: DateTime.now(),
),
);
}
final originRef = (await ChannelContentSource(rpc).manifest()).hash();
final reanchored = record.copyWith(
syncState: record.syncState.copyWith(
baselineRef: originRef,
status: SyncStatus.clean,
clearError: true,
),
);
return (await _syncDirectory(
reanchored,
rpc,
SyncDirection.push,
onProgress: onProgress,
)).record;
});
store.mounts[mountId] = updated;
await store.save();
return updated;
}