func (e *FileCacheEntry) readCloser() (*CachedFile, error) {
	var f *os.File
	var err error

	if e.fileDoesNotExist() {
		f, err = os.Create(e.FilePath)
		if err != nil {
			return nil, err
		}

		err = compressor.WriteTar(e.ExpandedDirectoryPath+"/", f)
		if err != nil {
			return nil, err
		}

		// If the directory is not used remove it
		if e.directoryInUseCount == 0 {
			err = os.RemoveAll(e.ExpandedDirectoryPath)
			if err != nil {
				fmt.Fprintln(os.Stderr, "Unable to remove cached directory", err)
			}
		} else {
			// Double the size to account for both assets
			e.Size = e.Size * 2
		}
	} else {
		f, err = os.Open(e.FilePath)
		if err != nil {
			return nil, err
		}
	}

	e.incrementFileInUseCount()

	if _, err := f.Seek(0, os.SEEK_SET); err != nil {
		return nil, err
	}

	readCloser := NewFileCloser(f, func(filePath string) {
		lock.Lock()
		e.decrementFileInUseCount()
		lock.Unlock()
	})

	return readCloser, nil
}
func (e *FileCacheEntry) readCloser() (*CachedFile, error) {
	var f *os.File
	var err error

	if e.fileDoesNotExist() {
		f, err = os.Create(e.FilePath)
		if err != nil {
			return nil, err
		}

		err = compressor.WriteTar(e.ExpandedDirectoryPath+"/", f)
		if err != nil {
			return nil, err
		}

		
		if e.directoryInUseCount == 0 {
			err = os.RemoveAll(e.ExpandedDirectoryPath)
			if err != nil {
				fmt.Fprintln(os.Stderr, "Unable to remove cached directory", err)
			}
		} else {
			
			e.Size = e.Size * 2
		}
	} else {
		f, err = os.Open(e.FilePath)
		if err != nil {
			return nil, err
		}
	}

	e.incrementFileInUseCount()

	if _, err := f.Seek(0, os.SEEK_SET); err != nil {
		return nil, err
	}

	readCloser := NewFileCloser(f, func(filePath string) {
		lock.Lock()
		e.decrementFileInUseCount()
		lock.Unlock()
	})

	return readCloser, nil
}
func ( e * FileCacheEntry ) readCloser ( ) ( * CachedFile , error ) { var f * os . File var err error if e . fileDoesNotExist ( ) { f , err = os . Create ( e . FilePath ) if err != nil { return nil , err } err = compressor . WriteTar ( e . ExpandedDirectoryPath + " " , f ) if err != nil { return nil , err } // If the directory is not used remove it if e . directoryInUseCount == 0 { err = os . RemoveAll ( e . ExpandedDirectoryPath ) if err != nil { fmt . Fprintln ( os . Stderr , " " , err ) } } else { // Double the size to account for both assets e . Size = e . Size * 2 } } else { f , err = os . Open ( e . FilePath ) if err != nil { return nil , err } } e . incrementFileInUseCount ( ) if _ , err := f . Seek ( 0 , os . SEEK_SET ) ; err != nil { return nil , err } readCloser := NewFileCloser ( f , func ( filePath string ) { lock . Lock ( ) e . decrementFileInUseCount ( ) lock . Unlock ( ) } ) return readCloser , nil }
// Can we change this to be an io.ReadCloser return
Can we change this to be an io . ReadCloser return