// NewArchiveRelTimeFile returns a special read file that contains a
// by-revision directory name that corresponds to the given relative
// time string for the given folder.
322203
func NewArchiveRelTimeFile(
	fs *FS, handle *tlfhandle.Handle, filename string,
	entryValid *time.Duration) *SpecialReadFile {
	*entryValid = 0
	return &SpecialReadFile{
		read: func(ctx context.Context) ([]byte, time.Time, error) {
			data, isRel, err := libfs.FileDataFromRelativeTimeString(
				ctx, fs.config, handle, filename)
			if err != nil {
				return nil, time.Time{}, err
			}
			if !isRel {
				panic("ArchiveRelTimeFile should only be used with " +
					"reltime file names")
			}
			return data, time.Time{}, nil
		},
	}
}
1029791
func NewRFile(f *File) (RFile, error) {
	data, err := fileData(f)
	if err != nil {
		return nil, err
	}
	return &file{f: f, data: data, readable: true}, nil
}
586614
func (m *UnpartitionedMemoryIdx) UpdateArchive(archive idx.Archive) {
	m.Lock()
	defer m.Unlock()
	if _, ok := m.defById[archive.Id]; !ok {
		return
	}
	*(m.defById[archive.Id]) = archive
}
540817
func NewFileRenameDetails(RelocateActionDetails []*RelocateAssetReferencesLogInfo) *FileRenameDetails {
	s := new(FileRenameDetails)
	s.RelocateActionDetails = RelocateActionDetails
	return s
}
692640
func NewSharedFolderMetadata(AccessType *AccessLevel, IsInsideTeamFolder bool, IsTeamFolder bool, Name string, Policy *FolderPolicy, PreviewUrl string, SharedFolderId string, TimeInvited time.Time) *SharedFolderMetadata {
	s := new(SharedFolderMetadata)
	s.AccessType = AccessType
	s.IsInsideTeamFolder = IsInsideTeamFolder
	s.IsTeamFolder = IsTeamFolder
	s.Name = Name
	s.Policy = Policy
	s.PreviewUrl = PreviewUrl
	s.SharedFolderId = SharedFolderId
	s.TimeInvited = TimeInvited
	s.AccessInheritance = &AccessInheritance{Tagged: dropbox.Tagged{"inherit"}}
	return s
}
996906
func NewRepoFile() *RepoFile {
	return &RepoFile{
		APIVersion:   APIVersionV1,
		Generated:    time.Now(),
		Repositories: []*Entry{},
	}
}
802701
func (h *ArchiveHandler) newArchiveToGuest(u *url.URL) (File, error) {
	r, w := io.Pipe()

	buf := bufio.NewReader(r)

	a := &archive{
		name:   u.Path,
		Reader: buf,
		Writer: w,
	}

	var cerr error
	var wg sync.WaitGroup

	a.done = func() error {
		_ = w.Close()
		// We need to wait for unpack to finish to complete its work
		// and to propagate the error if any to Close.
		wg.Wait()
		return cerr
	}

	wg.Add(1)
	go func() {
		defer wg.Done()

		c := func() error {
			// Drain the pipe of tar trailer data (two null blocks)
			if cerr == nil {
				_, _ = io.Copy(ioutil.Discard, a.Reader)
			}
			return nil
		}

		header, _ := buf.Peek(len(gzipHeader))

		if bytes.Equal(header, gzipHeader) {
			gz, err := gzip.NewReader(a.Reader)
			if err != nil {
				_ = r.CloseWithError(err)
				cerr = err
				return
			}

			c = gz.Close
			a.Reader = gz
		}

		tr := tar.NewReader(a.Reader)

		cerr = h.Read(u, tr)

		_ = c()
		_ = r.CloseWithError(cerr)
	}()

	return a, nil
}
1038954
func NewArchiver(idMappings *idtools.IDMappings) *archive.Archiver {
	archiver := archive.NewArchiver(idMappings)
	archiver.Untar = Untar
	return archiver
}
1048692
func FileDataFromRelativeTimeString(
	ctx context.Context, config libkbfs.Config, h *tlfhandle.Handle,
	filename string) ([]byte, bool, error) {
	if !strings.HasPrefix(filename, ArchivedRelTimeFilePrefix) {
		return nil, false, nil
	}

	rev, err := RevFromRelativeTimeString(
		ctx, config, h, filename[len(ArchivedRelTimeFilePrefix):])
	if err != nil {
		return nil, false, err
	}

	return []byte(ArchivedRevDirPrefix + strconv.FormatInt(int64(rev), 10)),
		true, nil
}
196223
func NewArchiveAPI(client *Client) *ArchiveAPI {
	api := &ArchiveAPI{
		baseAPI: &baseAPI{
			client: client,
			FuncGetResourceURL: func() string {
				return "archive"
			},
		},
	}

	api.findFuncMapPerOSType = map[ostype.ArchiveOSTypes]func() (*sacloud.Archive, error){
		ostype.CentOS:                              api.FindLatestStableCentOS,
		ostype.CentOS6:                             api.FindLatestStableCentOS6,
		ostype.Ubuntu:                              api.FindLatestStableUbuntu,
		ostype.Debian:                              api.FindLatestStableDebian,
		ostype.VyOS:                                api.FindLatestStableVyOS,
		ostype.CoreOS:                              api.FindLatestStableCoreOS,
		ostype.RancherOS:                           api.FindLatestStableRancherOS,
		ostype.Kusanagi:                            api.FindLatestStableKusanagi,
		ostype.SophosUTM:                           api.FindLatestStableSophosUTM,
		ostype.FreeBSD:                             api.FindLatestStableFreeBSD,
		ostype.Netwiser:                            api.FindLatestStableNetwiser,
		ostype.OPNsense:                            api.FindLatestStableOPNsense,
		ostype.Windows2012:                         api.FindLatestStableWindows2012,
		ostype.Windows2012RDS:                      api.FindLatestStableWindows2012RDS,
		ostype.Windows2012RDSOffice:                api.FindLatestStableWindows2012RDSOffice,
		ostype.Windows2016:                         api.FindLatestStableWindows2016,
		ostype.Windows2016RDS:                      api.FindLatestStableWindows2016RDS,
		ostype.Windows2016RDSOffice:                api.FindLatestStableWindows2016RDSOffice,
		ostype.Windows2016SQLServerWeb:             api.FindLatestStableWindows2016SQLServerWeb,
		ostype.Windows2016SQLServerStandard:        api.FindLatestStableWindows2016SQLServerStandard,
		ostype.Windows2016SQLServer2017Standard:    api.FindLatestStableWindows2016SQLServer2017Standard,
		ostype.Windows2016SQLServerStandardAll:     api.FindLatestStableWindows2016SQLServerStandardAll,
		ostype.Windows2016SQLServer2017StandardAll: api.FindLatestStableWindows2016SQLServer2017StandardAll,
	}

	return api
}
1151661
func (c SimpleFSClient) SimpleFSFolderEditHistory(ctx context.Context, path Path) (res FSFolderEditHistory, err error) {
	__arg := SimpleFSFolderEditHistoryArg{Path: path}
	err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSFolderEditHistory", []interface{}{__arg}, &res)
	return
}
767717
func NewMfiWithSrcLen(sourceLength uint, timePeriod int) (indicator *Mfi, err error) {
	ind, err := NewMfi(timePeriod)

	// only initialise the storage if there is enough source data to require it
	if sourceLength-uint(ind.GetLookbackPeriod()) > 1 {
		ind.Data = make([]float64, 0, sourceLength-uint(ind.GetLookbackPeriod()))
	}

	return ind, err
}
542786
func NewFileStorage(path string) (ResponseStorage, error) {
	file, err := ioutil.TempFile(path, "caddy-cache-")
	if err != nil {
		return nil, err
	}
	return &FileStorage{
		file:         file,
		subscription: NewSubscription(),
	}, nil
}
411675
func (fs *KBFSOpsStandard) RefreshEditHistory(fav favorites.Folder) {
	fbo := fs.getOpsByFav(fav)
	if fbo != nil {
		fbo.refreshEditHistory()
	}
}
463566
func (c *Client) UploadGUIArchive(r io.ReadSeeker, hash string, size int64, vers version.Number) (current bool, err error) {
	// Prepare the request.
	v := url.Values{}
	v.Set("version", vers.String())
	v.Set("hash", hash)
	req, err := http.NewRequest("POST", guiArchivePath+"?"+v.Encode(), nil)
	if err != nil {
		return false, errors.Annotate(err, "cannot create upload request")
	}
	req.Header.Set("Content-Type", "application/x-tar-bzip2")
	req.ContentLength = size

	// Retrieve a client and send the request.
	httpClient, err := c.facade.RawAPICaller().HTTPClient()
	if err != nil {
		return false, errors.Annotate(err, "cannot retrieve HTTP client")
	}
	var resp params.GUIArchiveVersion
	if err = httpClient.Do(req, r, &resp); err != nil {
		return false, errors.Annotate(err, "cannot upload the GUI archive")
	}
	return resp.Current, nil
}
307556
func NewTlfEditHistoryFile(folder *Folder) *SpecialReadFile {
	return &SpecialReadFile{
		read: func(ctx context.Context) ([]byte, time.Time, error) {
			return libfs.GetEncodedTlfEditHistory(
				ctx, folder.fs.config, folder.getFolderBranch())
		},
		fs: folder.fs,
	}
}
1034181
func NewBytesWatchDelResp(key string, prevValue []byte, revision int64) *BytesWatchDelResp {
	return &BytesWatchDelResp{key: key, prevValue: prevValue, rev: revision}
}