Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
b4ea8f84
Commit
b4ea8f84
authored
Nov 05, 2015
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix leftovers after middleware concept merge.
parent
43b75c8c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
54 deletions
+54
-54
archive.go
archive.go
+1
-1
git-http.go
git-http.go
+2
-2
lfs.go
lfs.go
+51
-50
upstream.go
upstream.go
+0
-1
No files found.
archive.go
View file @
b4ea8f84
...
@@ -16,7 +16,7 @@ import (
...
@@ -16,7 +16,7 @@ import (
"time"
"time"
)
)
func
handleGetArchive
(
w
http
.
ResponseWriter
,
r
*
gitRequest
,
format
string
)
(
callback
*
gitRequest
)
{
func
handleGetArchive
(
w
http
.
ResponseWriter
,
r
*
gitRequest
,
format
string
)
{
archiveFilename
:=
path
.
Base
(
r
.
ArchivePath
)
archiveFilename
:=
path
.
Base
(
r
.
ArchivePath
)
if
cachedArchive
,
err
:=
os
.
Open
(
r
.
ArchivePath
);
err
==
nil
{
if
cachedArchive
,
err
:=
os
.
Open
(
r
.
ArchivePath
);
err
==
nil
{
...
...
git-http.go
View file @
b4ea8f84
...
@@ -12,7 +12,7 @@ import (
...
@@ -12,7 +12,7 @@ import (
"strings"
"strings"
)
)
func
handleGetInfoRefs
(
w
http
.
ResponseWriter
,
r
*
gitRequest
,
_
string
)
(
callback
*
gitRequest
)
{
func
handleGetInfoRefs
(
w
http
.
ResponseWriter
,
r
*
gitRequest
,
_
string
)
{
rpc
:=
r
.
URL
.
Query
()
.
Get
(
"service"
)
rpc
:=
r
.
URL
.
Query
()
.
Get
(
"service"
)
if
!
(
rpc
==
"git-upload-pack"
||
rpc
==
"git-receive-pack"
)
{
if
!
(
rpc
==
"git-upload-pack"
||
rpc
==
"git-receive-pack"
)
{
// The 'dumb' Git HTTP protocol is not supported
// The 'dumb' Git HTTP protocol is not supported
...
@@ -58,7 +58,7 @@ func handleGetInfoRefs(w http.ResponseWriter, r *gitRequest, _ string) (callback
...
@@ -58,7 +58,7 @@ func handleGetInfoRefs(w http.ResponseWriter, r *gitRequest, _ string) (callback
return
return
}
}
func
handlePostRPC
(
w
http
.
ResponseWriter
,
r
*
gitRequest
,
rpc
string
)
(
callback
*
gitRequest
)
{
func
handlePostRPC
(
w
http
.
ResponseWriter
,
r
*
gitRequest
,
rpc
string
)
{
var
body
io
.
ReadCloser
var
body
io
.
ReadCloser
var
err
error
var
err
error
...
...
lfs.go
View file @
b4ea8f84
...
@@ -23,7 +23,7 @@ var (
...
@@ -23,7 +23,7 @@ var (
errSizeMismatch
=
errors
.
New
(
"Content size does not match"
)
errSizeMismatch
=
errors
.
New
(
"Content size does not match"
)
)
)
func
handleStoreLfsObject
(
w
http
.
ResponseWriter
,
r
*
gitRequest
,
rpc
string
)
(
callback
*
gitRequest
)
{
func
handleStoreLfsObject
(
w
http
.
ResponseWriter
,
r
*
gitRequest
,
rpc
string
)
{
var
body
io
.
ReadCloser
var
body
io
.
ReadCloser
urlPath
:=
r
.
URL
.
Path
urlPath
:=
r
.
URL
.
Path
...
@@ -42,63 +42,64 @@ func handleStoreLfsObject(w http.ResponseWriter, r *gitRequest, rpc string) (cal
...
@@ -42,63 +42,64 @@ func handleStoreLfsObject(w http.ResponseWriter, r *gitRequest, rpc string) (cal
storePath
:=
filepath
.
Join
(
r
.
StoreLFSPath
,
transformKey
(
oid
))
storePath
:=
filepath
.
Join
(
r
.
StoreLFSPath
,
transformKey
(
oid
))
if
_
,
err
:=
os
.
Stat
(
storePath
);
os
.
IsNotExist
(
err
)
{
if
_
,
err
:=
os
.
Stat
(
storePath
);
os
.
IsNotExist
(
err
)
{
var
err
error
tmpPath
:=
filepath
.
Join
(
r
.
StoreLFSPath
,
"tmp"
,
oid
)
tmpPath
:=
filepath
.
Join
(
r
.
StoreLFSPath
,
"tmp"
,
oid
)
// TODO try removing gzip, possibly not needed
if
_
,
err
:=
os
.
Stat
(
tmpPath
);
os
.
IsNotExist
(
err
)
{
// The client request body may have been gzipped.
// TODO try removing gzip, possibly not needed
if
r
.
Header
.
Get
(
"Content-Encoding"
)
==
"gzip"
{
// The client request body may have been gzipped.
body
,
err
=
gzip
.
NewReader
(
r
.
Body
)
if
r
.
Header
.
Get
(
"Content-Encoding"
)
==
"gzip"
{
if
err
!=
nil
{
body
,
err
=
gzip
.
NewReader
(
r
.
Body
)
fail500
(
w
,
"Couldn't handle LFS upload request."
,
err
)
if
err
!=
nil
{
return
fail500
(
w
,
"Couldn't handle LFS upload request."
,
err
)
return
}
}
else
{
body
=
r
.
Body
}
}
}
else
{
defer
body
.
Close
()
body
=
r
.
Body
}
defer
body
.
Close
()
// TODO maybe set dir permissions to 700
// TODO maybe set dir permissions to 700
dir
:=
filepath
.
Dir
(
tmpPath
)
dir
:=
filepath
.
Dir
(
tmpPath
)
if
err
:=
os
.
MkdirAll
(
dir
,
0750
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
dir
,
0750
);
err
!=
nil
{
fail500
(
w
,
"Couldn't create directory for storing LFS objects."
,
err
)
fail500
(
w
,
"Couldn't create directory for storing LFS objects."
,
err
)
return
return
}
}
// TODO use go library for creating TMP files
// TODO use go library for creating TMP files
file
,
err
:=
os
.
OpenFile
(
tmpPath
,
os
.
O_CREATE
|
os
.
O_WRONLY
|
os
.
O_EXCL
,
0640
)
file
,
err
:=
os
.
OpenFile
(
tmpPath
,
os
.
O_CREATE
|
os
.
O_WRONLY
|
os
.
O_EXCL
,
0640
)
if
err
!=
nil
{
if
err
!=
nil
{
fail500
(
w
,
"Couldn't open tmp file for writing."
,
err
)
fail500
(
w
,
"Couldn't open tmp file for writing."
,
err
)
return
return
}
}
// defer os.Remove(tmpPath)
// defer os.Remove(tmpPath)
defer
file
.
Close
()
defer
file
.
Close
()
hash
:=
sha256
.
New
()
hash
:=
sha256
.
New
()
hw
:=
io
.
MultiWriter
(
hash
,
file
)
hw
:=
io
.
MultiWriter
(
hash
,
file
)
written
,
err
:=
io
.
Copy
(
hw
,
body
)
written
,
err
:=
io
.
Copy
(
hw
,
body
)
if
err
!=
nil
{
if
err
!=
nil
{
fail500
(
w
,
"Failed to save received LFS object."
,
err
)
fail500
(
w
,
"Failed to save received LFS object."
,
err
)
return
return
}
}
file
.
Close
()
file
.
Close
()
sizeInt
,
err
:=
strconv
.
ParseInt
(
size
,
10
,
64
)
sizeInt
,
err
:=
strconv
.
ParseInt
(
size
,
10
,
64
)
if
err
!=
nil
{
if
err
!=
nil
{
fail500
(
w
,
"Couldn't read size: "
,
err
)
fail500
(
w
,
"Couldn't read size: "
,
err
)
return
return
}
}
if
written
!=
sizeInt
{
if
written
!=
sizeInt
{
fail500
(
w
,
"Inconsistent size: "
,
errSizeMismatch
)
fail500
(
w
,
"Inconsistent size: "
,
errSizeMismatch
)
return
return
}
}
shaStr
:=
hex
.
EncodeToString
(
hash
.
Sum
(
nil
))
shaStr
:=
hex
.
EncodeToString
(
hash
.
Sum
(
nil
))
if
shaStr
!=
oid
{
if
shaStr
!=
oid
{
fail500
(
w
,
"Inconsistent size: "
,
errSizeMismatch
)
fail500
(
w
,
"Inconsistent size: "
,
errSizeMismatch
)
return
return
}
}
}
}
}
// if err := os.Rename(tmpPath, path); err != nil {
// if err := os.Rename(tmpPath, path); err != nil {
...
@@ -108,11 +109,11 @@ func handleStoreLfsObject(w http.ResponseWriter, r *gitRequest, rpc string) (cal
...
@@ -108,11 +109,11 @@ func handleStoreLfsObject(w http.ResponseWriter, r *gitRequest, rpc string) (cal
log
.
Printf
(
"Received the LFS object from client, oid: %s"
,
oid
)
log
.
Printf
(
"Received the LFS object from client, oid: %s"
,
oid
)
return
r
return
}
}
func
handleRetreiveLfsObject
(
w
http
.
ResponseWriter
,
r
*
gitRequest
,
rpc
string
)
(
callback
*
gitRequest
)
{
func
handleRetreiveLfsObject
(
w
http
.
ResponseWriter
,
r
*
gitRequest
,
rpc
string
)
{
log
.
Printf
(
"I should download %s"
,
r
)
log
.
Printf
(
"I should download %s"
,
r
)
urlPath
:=
r
.
URL
.
Path
urlPath
:=
r
.
URL
.
Path
...
...
upstream.go
View file @
b4ea8f84
...
@@ -179,4 +179,3 @@ func looksLikeRepo(p string) bool {
...
@@ -179,4 +179,3 @@ func looksLikeRepo(p string) bool {
}
}
return
true
return
true
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment