@@ -146,36 +146,23 @@ struct PathInputScheme : InputScheme
146146 auto absPath = getAbsPath (input);
147147
148148 // FIXME: check whether access to 'path' is allowed.
149+
150+ auto accessor = makeFSSourceAccessor (absPath);
151+
149152 auto storePath = store.maybeParseStorePath (absPath.string ());
150153
151- if (storePath)
154+ if (storePath) {
152155 store.addTempRoot (*storePath);
153156
154- time_t mtime = 0 ;
155- if (!storePath || storePath-> name () != " source " || !store. isValidPath (*storePath)) {
156- Activity act (*logger, lvlTalkative, actUnknown, fmt ( " copying %s to the store" , absPath) );
157- // FIXME: try to substitute storePath.
158- auto src = sinkToSource (
159- [&](Sink & sink) { mtime = dumpPathAndGetMtime (absPath. string (), sink, defaultPathFilter); });
160- storePath = store. addToStoreFromDump (*src, " source " );
157+ // To prevent `fetchToStore()` copying the path again to Nix
158+ // store, pre-create an entry in the fetcher cache.
159+ auto info = store. queryPathInfo (*storePath );
160+ accessor-> fingerprint = fmt ( " path:%s " , info-> narHash . to_string (HashFormat:: SRI , true ));
161+ settings. getCache ()-> upsert (
162+ makeSourcePathToHashCacheKey (*accessor-> fingerprint , ContentAddressMethod::Raw::NixArchive, " / " ),
163+ {{ " hash " , info-> narHash . to_string (HashFormat:: SRI , true )}} );
161164 }
162165
163- auto accessor = store.requireStoreObjectAccessor (*storePath);
164-
165- // To prevent `fetchToStore()` copying the path again to Nix
166- // store, pre-create an entry in the fetcher cache.
167- auto info = store.queryPathInfo (*storePath);
168- accessor->fingerprint =
169- fmt (" path:%s" , store.queryPathInfo (*storePath)->narHash .to_string (HashFormat::SRI , true ));
170- settings.getCache ()->upsert (
171- makeSourcePathToHashCacheKey (*accessor->fingerprint , ContentAddressMethod::Raw::NixArchive, " /" ),
172- {{" hash" , info->narHash .to_string (HashFormat::SRI , true )}});
173-
174- /* Trust the lastModified value supplied by the user, if
175- any. It's not a "secure" attribute so we don't care. */
176- if (!input.getLastModified ())
177- input.attrs .insert_or_assign (" lastModified" , uint64_t (mtime));
178-
179166 return {accessor, std::move (input)};
180167 }
181168};
0 commit comments