diff options
Diffstat (limited to 'cmd/git-lfs-server')
-rw-r--r-- | cmd/git-lfs-server/main.go | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/cmd/git-lfs-server/main.go b/cmd/git-lfs-server/main.go index e5c0788..cfad3e0 100644 --- a/cmd/git-lfs-server/main.go +++ b/cmd/git-lfs-server/main.go | |||
@@ -730,11 +730,7 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |||
730 | } | 730 | } |
731 | }() | 731 | }() |
732 | 732 | ||
733 | reqPath := os.Getenv("PATH_INFO") | 733 | reqPath := strings.TrimPrefix(path.Clean(r.URL.Path), "/") |
734 | if reqPath == "" { | ||
735 | reqPath = r.URL.Path | ||
736 | } | ||
737 | reqPath = strings.TrimPrefix(path.Clean(reqPath), "/") | ||
738 | 734 | ||
739 | if submatches := reBatchAPI.FindStringSubmatch(reqPath); len(submatches) == 2 { | 735 | if submatches := reBatchAPI.FindStringSubmatch(reqPath); len(submatches) == 2 { |
740 | if r.Method != http.MethodPost { | 736 | if r.Method != http.MethodPost { |
@@ -824,17 +820,17 @@ func wipe(b []byte) { | |||
824 | } | 820 | } |
825 | 821 | ||
826 | func main() { | 822 | func main() { |
827 | anonUser := os.Getenv("ANON_USER") | 823 | anonUser := os.Getenv("GITOLFS3_ANON_USER") |
828 | privateKeyPath := os.Getenv("GITOLFS3_PRIVATE_KEY_PATH") | 824 | privateKeyPath := os.Getenv("GITOLFS3_PRIVATE_KEY_PATH") |
829 | endpoint := os.Getenv("S3_ENDPOINT") | 825 | endpoint := os.Getenv("GITOLFS3_S3_ENDPOINT") |
830 | bucket := os.Getenv("S3_BUCKET") | 826 | bucket := os.Getenv("GITOLFS3_S3_BUCKET") |
831 | accessKeyIDFile := os.Getenv("S3_ACCESS_KEY_ID_FILE") | 827 | accessKeyIDFile := os.Getenv("GITOLFS3_S3_ACCESS_KEY_ID_FILE") |
832 | secretAccessKeyFile := os.Getenv("S3_SECRET_ACCESS_KEY_FILE") | 828 | secretAccessKeyFile := os.Getenv("GITOLFS3_S3_SECRET_ACCESS_KEY_FILE") |
833 | gitolitePath := os.Getenv("GITOLITE_PATH") | 829 | gitolitePath := os.Getenv("GITOLFS3_GITOLITE_PATH") |
834 | baseURLStr := os.Getenv("BASE_URL") | 830 | baseURLStr := os.Getenv("GITOLFS3_BASE_URL") |
835 | listenHost := os.Getenv("LISTEN_HOST") | 831 | listenHost := os.Getenv("GITOLFS3_LISTEN_HOST") |
836 | listenPort := os.Getenv("LISTEN_PORT") | 832 | listenPort := os.Getenv("GITOLFS3_LISTEN_PORT") |
837 | exportAllForwardedHostsStr := os.Getenv("EXPORT_ALL_FORWARDED_HOSTS") | 833 | exportAllForwardedHostsStr := os.Getenv("GITOLFS3_EXPORT_ALL_FORWARDED_HOSTS") |
838 | 834 | ||
839 | listenAddr := net.JoinHostPort(listenHost, listenPort) | 835 | listenAddr := net.JoinHostPort(listenHost, listenPort) |
840 | exportAllForwardedHosts := strings.Split(exportAllForwardedHostsStr, ",") | 836 | exportAllForwardedHosts := strings.Split(exportAllForwardedHostsStr, ",") |
@@ -844,29 +840,29 @@ func main() { | |||
844 | } | 840 | } |
845 | 841 | ||
846 | if anonUser == "" { | 842 | if anonUser == "" { |
847 | die("Fatal: expected environment variable ANON_USER to be set") | 843 | die("Fatal: expected environment variable GITOLFS3_ANON_USER to be set") |
848 | } | 844 | } |
849 | if privateKeyPath == "" { | 845 | if privateKeyPath == "" { |
850 | die("Fatal: expected environment variable GITOLFS3_PRIVATE_KEY_PATH to be set") | 846 | die("Fatal: expected environment variable GITOLFS3_PRIVATE_KEY_PATH to be set") |
851 | } | 847 | } |
852 | if listenPort == "" { | 848 | if listenPort == "" { |
853 | die("Fatal: expected environment variable LISTEN_PORT to be set") | 849 | die("Fatal: expected environment variable GITOLFS3_LISTEN_PORT to be set") |
854 | } | 850 | } |
855 | if baseURLStr == "" { | 851 | if baseURLStr == "" { |
856 | die("Fatal: expected environment variable BASE_URL to be set") | 852 | die("Fatal: expected environment variable GITOLFS3_BASE_URL to be set") |
857 | } | 853 | } |
858 | if endpoint == "" { | 854 | if endpoint == "" { |
859 | die("Fatal: expected environment variable S3_ENDPOINT to be set") | 855 | die("Fatal: expected environment variable GITOLFS3_S3_ENDPOINT to be set") |
860 | } | 856 | } |
861 | if bucket == "" { | 857 | if bucket == "" { |
862 | die("Fatal: expected environment variable S3_BUCKET to be set") | 858 | die("Fatal: expected environment variable GITOLFS3_S3_BUCKET to be set") |
863 | } | 859 | } |
864 | 860 | ||
865 | if accessKeyIDFile == "" { | 861 | if accessKeyIDFile == "" { |
866 | die("Fatal: expected environment variable S3_ACCESS_KEY_ID_FILE to be set") | 862 | die("Fatal: expected environment variable GITOLFS3_S3_ACCESS_KEY_ID_FILE to be set") |
867 | } | 863 | } |
868 | if secretAccessKeyFile == "" { | 864 | if secretAccessKeyFile == "" { |
869 | die("Fatal: expected environment variable S3_SECRET_ACCESS_KEY_FILE to be set") | 865 | die("Fatal: expected environment variable GITOLFS3_S3_SECRET_ACCESS_KEY_FILE to be set") |
870 | } | 866 | } |
871 | 867 | ||
872 | accessKeyID, err := os.ReadFile(accessKeyIDFile) | 868 | accessKeyID, err := os.ReadFile(accessKeyIDFile) |
@@ -899,11 +895,3 @@ func main() { | |||
899 | die("Fatal: failed to serve CGI: %s", err) | 895 | die("Fatal: failed to serve CGI: %s", err) |
900 | } | 896 | } |
901 | } | 897 | } |
902 | |||
903 | // Directory stucture: | ||
904 | // - lfs/ | ||
905 | // - locks/ | ||
906 | // - objects/ | ||
907 | // - <1st OID byte> | ||
908 | // - <2nd OID byte> | ||
909 | // - <OID hash> <- this is the object | ||