@@ -84,27 +84,29 @@ export async function readRemotes(options: any): Promise<Record<string, Record<s
8484 return byUUID
8585}
8686
87- /**
88- * Resolve an annexed file location to an HTTP URL, if a public S3 remote is available
89- */
90- export async function resolveAnnexedFile (
87+ export async function parseAnnexedFile (
9188 path : string ,
92- remote ?: string ,
93- options ?: any ,
94- ) : Promise < { url : string ; size : number } > {
95- // path is known to be a symlink
89+ ) : Promise < { key : string ; size : number ; gitdir : string } > {
9690 const target = await Deno . readLink ( path )
9791 const { dir, base } = parse ( target )
9892
99- if ( ! options ?. gitdir ) {
100- const dirs = dir . split ( SEPARATOR_PATTERN )
101- const gitdir = join ( dirname ( path ) , ...dirs . slice ( 0 , dirs . indexOf ( '.git' ) + 1 ) )
102- options = { ...options , gitdir }
103- }
93+ const dirs = dir . split ( SEPARATOR_PATTERN )
94+ const gitdir = join ( dirname ( path ) , ...dirs . slice ( 0 , dirs . indexOf ( '.git' ) + 1 ) )
10495
10596 const size = + base . match ( annexKeyRegex ) ?. groups ?. size !
10697
107- const rmet = await readRmet ( base , options )
98+ return { key : base , size, gitdir }
99+ }
100+
101+ /**
102+ * Resolve an annexed file location to an HTTP URL, if a public S3 remote is available
103+ */
104+ export async function resolveAnnexedFile (
105+ key : string ,
106+ remote ?: string ,
107+ options ?: any ,
108+ ) : Promise < { url : string } > {
109+ const rmet = await readRmet ( key , options )
108110 const remotes = await readRemotes ( options )
109111 let uuid : string
110112 if ( remote ) {
@@ -137,5 +139,5 @@ export async function resolveAnnexedFile(
137139 const metadata = rmet [ uuid ]
138140 const url = `${ publicurl } /${ metadata . path } ?versionId=${ metadata . version } `
139141
140- return { url, size }
142+ return { url }
141143}
0 commit comments