mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Merge pull request #17732 from Microsoft/sjw/archive_access_time_fix
Fixing last access time on Windows to unblock python.
This commit is contained in:
		
						commit
						35d9bcdb57
					
				
					 2 changed files with 10 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -298,7 +298,7 @@ func (b *Builder) download(srcURL string) (fi builder.FileInfo, err error) {
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err = system.Chtimes(tmpFileName, time.Time{}, mTime); err != nil {
 | 
			
		||||
	if err = system.Chtimes(tmpFileName, mTime, mTime); err != nil {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -407,19 +407,25 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L
 | 
			
		|||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	aTime := hdr.AccessTime
 | 
			
		||||
	if aTime.Before(hdr.ModTime) {
 | 
			
		||||
		// Last access time should never be before last modified time.
 | 
			
		||||
		aTime = hdr.ModTime
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// system.Chtimes doesn't support a NOFOLLOW flag atm
 | 
			
		||||
	if hdr.Typeflag == tar.TypeLink {
 | 
			
		||||
		if fi, err := os.Lstat(hdr.Linkname); err == nil && (fi.Mode()&os.ModeSymlink == 0) {
 | 
			
		||||
			if err := system.Chtimes(path, hdr.AccessTime, hdr.ModTime); err != nil {
 | 
			
		||||
			if err := system.Chtimes(path, aTime, hdr.ModTime); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	} else if hdr.Typeflag != tar.TypeSymlink {
 | 
			
		||||
		if err := system.Chtimes(path, hdr.AccessTime, hdr.ModTime); err != nil {
 | 
			
		||||
		if err := system.Chtimes(path, aTime, hdr.ModTime); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		ts := []syscall.Timespec{timeToTimespec(hdr.AccessTime), timeToTimespec(hdr.ModTime)}
 | 
			
		||||
		ts := []syscall.Timespec{timeToTimespec(aTime), timeToTimespec(hdr.ModTime)}
 | 
			
		||||
		if err := system.LUtimesNano(path, ts); err != nil && err != system.ErrNotSupportedPlatform {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue