1
0
mirror of https://github.com/IceWhaleTech/CasaOS.git synced 2025-07-12 23:50:14 +02:00

added google drive

This commit is contained in:
link
2023-01-16 05:54:44 +00:00
parent be50579544
commit 87d8be8c61
47 changed files with 3711 additions and 67 deletions

34
service/storage_path.go Normal file
View File

@ -0,0 +1,34 @@
package service
import (
"strings"
"github.com/IceWhaleTech/CasaOS-Common/utils/logger"
"github.com/IceWhaleTech/CasaOS/internal/driver"
"github.com/IceWhaleTech/CasaOS/pkg/utils"
"github.com/pkg/errors"
"go.uber.org/zap"
)
type StoragePathService interface {
GetStorageAndActualPath(rawPath string) (storage driver.Driver, actualPath string, err error)
}
type storagePathStruct struct {
}
func (s *storagePathStruct) GetStorageAndActualPath(rawPath string) (storage driver.Driver, actualPath string, err error) {
rawPath = utils.FixAndCleanPath(rawPath)
storage = MyService.Storages().GetBalancedStorage(rawPath)
if storage == nil {
err = errors.Errorf("can't find storage with rawPath: %s", rawPath)
return
}
logger.Info("use storage", zap.Any("storage mount path", storage.GetStorage().MountPath))
mountPath := utils.GetActualMountPath(storage.GetStorage().MountPath)
actualPath = utils.FixAndCleanPath(strings.TrimPrefix(rawPath, mountPath))
return
}
func NewStoragePathService() StoragePathService {
return &storagePathStruct{}
}