| ... | ... | @@ -331,9 +331,17 @@ pub fn run(f: *Fetch) RunError!void { |
| 331 | 331 | // prefix of "p/$hash/". |
| 332 | 332 | const prefix_len: usize = if (f.job_queue.read_only) 0 else "p/".len; |
| 333 | 333 | const parent_sub_path = f.parent_package_root.sub_path; |
| 334 | | const end = std.mem.indexOfScalarPos(u8, parent_sub_path, prefix_len, fs.path.sep) orelse |
| 335 | | parent_sub_path.len; |
| 336 | | const expected_prefix = parent_sub_path[prefix_len..end]; |
| 334 | const end = find_end: { |
| 335 | if (parent_sub_path.len > prefix_len) { |
| 336 | // Use `isSep` instead of `indexOfScalarPos` to account for |
| 337 | // Windows accepting both `\` and `/` as path separators. |
| 338 | for (parent_sub_path[prefix_len..], prefix_len..) |c, i| { |
| 339 | if (std.fs.path.isSep(c)) break :find_end i; |
| 340 | } |
| 341 | } |
| 342 | break :find_end parent_sub_path.len; |
| 343 | }; |
| 344 | const expected_prefix = parent_sub_path[0..end]; |
| 337 | 345 | if (!std.mem.startsWith(u8, pkg_root.sub_path, expected_prefix)) { |
| 338 | 346 | return f.fail( |
| 339 | 347 | f.location_tok, |