Updated mounted_file_system.go.

geesefs-0-30-9
Aaron Jacobs 2015-05-25 14:18:50 +10:00
parent 438929753f
commit 430fbb3099
1 changed files with 15 additions and 3 deletions

View File

@ -16,6 +16,7 @@ package fuse
import ( import (
"fmt" "fmt"
"io/ioutil"
"log" "log"
"runtime" "runtime"
@ -154,7 +155,7 @@ func Mount(
dir string, dir string,
server Server, server Server,
config *MountConfig) (mfs *MountedFileSystem, err error) { config *MountConfig) (mfs *MountedFileSystem, err error) {
logger := getLogger() debugLogger := getDebugLogger()
// Initialize the struct. // Initialize the struct.
mfs = &MountedFileSystem{ mfs = &MountedFileSystem{
@ -163,7 +164,7 @@ func Mount(
} }
// Open a bazilfuse connection. // Open a bazilfuse connection.
logger.Println("Opening a bazilfuse connection.") debugLogger.Println("Opening a bazilfuse connection.")
bfConn, err := bazilfuse.Mount(mfs.dir, config.bazilfuseOptions()...) bfConn, err := bazilfuse.Mount(mfs.dir, config.bazilfuseOptions()...)
if err != nil { if err != nil {
err = fmt.Errorf("bazilfuse.Mount: %v", err) err = fmt.Errorf("bazilfuse.Mount: %v", err)
@ -176,8 +177,19 @@ func Mount(
opContext = context.Background() opContext = context.Background()
} }
// Create a /dev/null error logger if necessary.
errorLogger := config.ErrorLogger
if errorLogger == nil {
errorLogger = log.New(ioutil.Discard, "", 0)
}
// Create our own Connection object wrapping it. // Create our own Connection object wrapping it.
connection, err := newConnection(opContext, logger, bfConn) connection, err := newConnection(
opContext,
debugLogger,
errorLogger,
bfConn)
if err != nil { if err != nil {
bfConn.Close() bfConn.Close()
err = fmt.Errorf("newConnection: %v", err) err = fmt.Errorf("newConnection: %v", err)