func ImportBGIFromGoogleStorageLocked(bgiPath string, client *storage.Client) (memfsBIGPath string, newDownload bool, err error) {

	// The local filename will be:
	filename := os.TempDir() + "/" + filepath.Base(bgiPath)

	// Lock upgrading is racy. See https://github.com/golang/go/issues/4026#issuecomment-66069820

	// First step is to gain an RLock
	importBGIFromGoogleStorageLockedMutex.RLock()

	// Now we can ask if the file exists
	_, exists := importBGIFromGoogleStorageLookup[bgiPath]
	// Unlock regardless
	importBGIFromGoogleStorageLockedMutex.RUnlock()
	if exists {
		return filename, false, nil
	}

	// The file doesn't exist. It is no longer rlocked. Let's upgrade to a full
	// lock so we can fetch it in this goroutine.
	importBGIFromGoogleStorageLockedMutex.Lock()

	// Since it may take time to gain the Lock, check again: does the file
	// exist?
	_, exists = importBGIFromGoogleStorageLookup[bgiPath]
	if exists {
		importBGIFromGoogleStorageLockedMutex.Unlock()
		return filename, false, nil
	}

	// We now have the ball, and we know the file does not exist. Mutate.
	err = importBGIFromGoogleStorageLocked(bgiPath, filename, client)

	// Signify that we have the file now.
	importBGIFromGoogleStorageLookup[bgiPath] = struct{}{}

	// Signify that we are done and release the lock
	// delete(importBGIFromGoogleStorageLockedActive, bgiPath)
	importBGIFromGoogleStorageLockedMutex.Unlock()

	return filename, true, err
}
// ImportBGIFromGoogleStorageLocked copies the BGEN index from google storage to
// the local temp directory. This is necessary because SQLite reads from a
// filename, instead of a reader, and therefore can't be managed over the wire.
ImportBGIFromGoogleStorageLocked copies the BGEN index from google storage to
the local temp directory. This is necessary because SQLite reads from a
filename, instead of a reader, and therefore can't be managed over the wire.
// ImportBGIFromGoogleStorageLocked copies the BGEN index from google storage to // the local temp directory . This is necessary because SQLite reads from a // filename instead of a reader and therefore can ' t be managed over the wire .
func ImportBGIFromGoogleStorageLocked(bgiPath string, client *storage.Client) (memfsBIGPath string, newDownload bool, err error) {
	filename := os.TempDir() + "/" + filepath.Base(bgiPath)
	importBGIFromGoogleStorageLockedMutex.RLock()
	_, exists := importBGIFromGoogleStorageLookup[bgiPath]
	importBGIFromGoogleStorageLockedMutex.RUnlock()
	if exists {
		return filename, false, nil
	}
	importBGIFromGoogleStorageLockedMutex.Lock()
	_, exists = importBGIFromGoogleStorageLookup[bgiPath]
	if exists {
		importBGIFromGoogleStorageLockedMutex.Unlock()
		return filename, false, nil
	}
	err = importBGIFromGoogleStorageLocked(bgiPath, filename, client)
	importBGIFromGoogleStorageLookup[bgiPath] = struct{}{}
	importBGIFromGoogleStorageLockedMutex.Unlock()
	return filename, true, err
}
func ImportBGIFromGoogleStorageLocked ( bgiPath string , client * storage . Client ) ( memfsBIGPath string , newDownload bool , err error ) { filename := os . TempDir ( ) + " " + filepath . Base ( bgiPath ) importBGIFromGoogleStorageLockedMutex . RLock ( ) _ , exists := importBGIFromGoogleStorageLookup [ bgiPath ] importBGIFromGoogleStorageLockedMutex . RUnlock ( ) if exists { return filename , false , nil } importBGIFromGoogleStorageLockedMutex . Lock ( ) _ , exists = importBGIFromGoogleStorageLookup [ bgiPath ] if exists { importBGIFromGoogleStorageLockedMutex . Unlock ( ) return filename , false , nil } err = importBGIFromGoogleStorageLocked ( bgiPath , filename , client ) importBGIFromGoogleStorageLookup [ bgiPath ] = struct { } { } importBGIFromGoogleStorageLockedMutex . Unlock ( ) return filename , true , err }
ImportBGIFromGoogleStorageLocked copies the BGEN index from google storage to
the local temp directory.
ImportBGIFromGoogleStorageLocked copies the BGEN index from google storage to the local temp directory .
// The local filename will be: // Lock upgrading is racy. See https://github.com/golang/go/issues/4026#issuecomment-66069820 // First step is to gain an RLock // Now we can ask if the file exists // Unlock regardless // The file doesn't exist. It is no longer rlocked. Let's upgrade to a full // lock so we can fetch it in this goroutine. // Since it may take time to gain the Lock, check again: does the file // exist? // We now have the ball, and we know the file does not exist. Mutate. // Signify that we have the file now. // Signify that we are done and release the lock // delete(importBGIFromGoogleStorageLockedActive, bgiPath)