storage.go 629 B

1234567891011121314151617181920212223242526
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package lfsutil
  5. import (
  6. "path/filepath"
  7. )
  8. // Storage is the storage type of an LFS object.
  9. type Storage string
  10. const (
  11. StorageLocal Storage = "local"
  12. )
  13. // StorageLocalPath returns computed file path for storing object on local file system.
  14. // It returns empty string if given "oid" isn't valid.
  15. func StorageLocalPath(root string, oid OID) string {
  16. if !ValidOID(oid) {
  17. return ""
  18. }
  19. return filepath.Join(root, string(oid[0]), string(oid[1]), string(oid))
  20. }