code: func (s *sharedPullerState) finalClose() (bool, error) {
  	s.mut.Lock()
  	defer s.mut.Unlock()
  
  	if s.closed {
  		// Already closed
  		return false, nil
  	}
  
  	if s.pullNeeded+s.copyNeeded != 0 && s.err == nil {
  		// Not done yet, and not errored
  		return false, nil
  	}
  
  	if s.fd != nil {
  		// This is our error if we weren't errored before. Otherwise we
  		// keep the earlier error.
  		if fsyncErr := s.fd.Sync(); fsyncErr != nil && s.err == nil {
  			s.err = fsyncErr
  		}
  		if closeErr := s.fd.Close(); closeErr != nil && s.err == nil {
  			s.err = closeErr
  		}
  		s.fd = nil
  	}
  
  	s.closed = true
  
  	// Unhide the temporary file when we close it, as it's likely to
  	// immediately be renamed to the final name. If this is a failed temp
  	// file we will also unhide it, but I'm fine with that as we're now
  	// leaving it around for potentially quite a while.
  	s.fs.Unhide(s.tempName)
  
  	return true, s.err
  }
docs: // finalClose atomically closes and returns closed status of a file. A true
  // first return value means the file was closed and should be finished, with
  // the error indicating the success or failure of the close. A false first
  // return value indicates the file is not ready to be closed, or is already
  // closed and should in either case not be finished off now.