weed filer.copy: skip files that can not be opened

such as socket
This commit is contained in:
Chris Lu 2019-04-05 00:04:00 -07:00
parent 4f714cef22
commit 921231268b

View file

@ -1,25 +1,24 @@
package command package command
import ( import (
"context"
"fmt" "fmt"
"github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/security" "github.com/chrislusf/seaweedfs/weed/security"
"github.com/chrislusf/seaweedfs/weed/server" "github.com/chrislusf/seaweedfs/weed/server"
"github.com/chrislusf/seaweedfs/weed/util"
"github.com/chrislusf/seaweedfs/weed/wdclient" "github.com/chrislusf/seaweedfs/weed/wdclient"
"github.com/spf13/viper" "github.com/spf13/viper"
"google.golang.org/grpc" "google.golang.org/grpc"
"io"
"io/ioutil" "io/ioutil"
"net/http"
"net/url" "net/url"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"context"
"github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/util"
"io"
"net/http"
"strconv" "strconv"
"strings"
"time" "time"
) )
@ -123,6 +122,10 @@ func doEachCopy(ctx context.Context, fileOrDir string, filerAddress, filerGrpcAd
f, err := os.Open(fileOrDir) f, err := os.Open(fileOrDir)
if err != nil { if err != nil {
fmt.Printf("Failed to open file %s: %v\n", fileOrDir, err) fmt.Printf("Failed to open file %s: %v\n", fileOrDir, err)
if _, ok := err.(*os.PathError); ok {
fmt.Printf("skipping %s\n", fileOrDir)
return true
}
return false return false
} }
defer f.Close() defer f.Close()