@@ -148,7 +148,7 @@ func Run(options *RunOptions) (*Report, error) {
148148 // When creating content, record if a path is known and whether they are
149149 // listed as until: mutate in all the slices that reference them.
150150 knownPaths := map [string ]pathData {}
151- addParents (knownPaths , "/" )
151+ addKnownPath (knownPaths , "/" , pathData {} )
152152
153153 // Creates the filesystem entry and adds it to the report.
154154 create := func (extractInfos []deb.ExtractInfo , o * fsutil.CreateOptions ) error {
@@ -193,8 +193,8 @@ func Run(options *RunOptions) (*Report, error) {
193193 }
194194
195195 if inSliceContents {
196- knownPaths [ relPath ] = pathData {mutable : mutable , until : until }
197- addParents (knownPaths , relPath )
196+ data : = pathData {mutable : mutable , until : until }
197+ addKnownPath (knownPaths , relPath , data )
198198 }
199199 return nil
200200 }
@@ -231,7 +231,11 @@ func Run(options *RunOptions) (*Report, error) {
231231 continue
232232 }
233233 done [relPath ] = true
234- addParents (knownPaths , relPath )
234+ data := pathData {
235+ until : pathInfo .Until ,
236+ mutable : pathInfo .Mutable ,
237+ }
238+ addKnownPath (knownPaths , relPath , data )
235239 targetPath := filepath .Join (targetDir , relPath )
236240 entry , err := createFile (targetPath , pathInfo )
237241 if err != nil {
@@ -241,12 +245,6 @@ func Run(options *RunOptions) (*Report, error) {
241245 if err != nil {
242246 return nil , err
243247 }
244- if pathInfo .Until == setup .UntilMutate || pathInfo .Mutable {
245- knownPaths [relPath ] = pathData {
246- until : pathInfo .Until ,
247- mutable : pathInfo .Mutable ,
248- }
249- }
250248 }
251249 }
252250
@@ -313,9 +311,9 @@ func removeUntilMutate(rootDir string, knownPaths map[string]pathData) error {
313311 return nil
314312}
315313
316- // addParents adds all parent directories of path to the list of known paths.
317- // The path has to be absolute .
318- func addParents (knownPaths map [string ]pathData , path string ) {
314+ // addKnownPath adds a path with its data to the list of known paths. Then it
315+ // records that the parent directories of the path are also known .
316+ func addKnownPath (knownPaths map [string ]pathData , path string , data pathData ) {
319317 if ! strings .HasPrefix (path , "/" ) {
320318 panic ("bug: tried to add relative path to known paths" )
321319 }
@@ -325,9 +323,12 @@ func addParents(knownPaths map[string]pathData, path string) {
325323 slashPath += "/"
326324 }
327325 for {
328- if _ , ok := knownPaths [slashPath ]; ! ok {
329- knownPaths [ slashPath ] = pathData {}
326+ if _ , ok := knownPaths [slashPath ]; ok {
327+ break
330328 }
329+ knownPaths [slashPath ] = data
330+ // The parents have empty data.
331+ data = pathData {}
331332 cleanPath = filepath .Dir (cleanPath )
332333 if cleanPath == "/" {
333334 break
0 commit comments