aliyunpan/internal/functions/pandownload/utils.go
2021-10-10 10:48:53 +08:00

43 lines
1.2 KiB
Go

// Copyright (c) 2020 tickstep.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package pandownload
import (
"github.com/tickstep/aliyunpan-api/aliyunpan"
"os"
)
// CheckFileValid 检测文件有效性
func CheckFileValid(filePath string, fileInfo *aliyunpan.FileEntity) error {
// 检查MD5
// 检查文件大小
// 检查digest签名
return nil
}
// FileExist 检查文件是否存在,
// 只有当文件存在, 文件大小不为0或断点续传文件不存在时, 才判断为存在
func FileExist(path string) bool {
if info, err := os.Stat(path); err == nil {
if info.Size() == 0 {
return false
}
if _, err = os.Stat(path + DownloadSuffix); err != nil {
return true
}
}
return false
}