Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
fdbef6c9
"...text-generation-inference.git" did not exist on "942005386aed8b543c22fa6d7888af65e6c26c85"
Commit
fdbef6c9
authored
Jul 24, 2023
by
Bruce MacDonald
Browse files
truncate file size on resume
parent
a3297fed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
server/images.go
server/images.go
+9
-1
No files found.
server/images.go
View file @
fdbef6c9
...
@@ -913,6 +913,7 @@ func downloadBlob(mp ModelPath, digest string, regOpts *RegistryOptions, fn func
...
@@ -913,6 +913,7 @@ func downloadBlob(mp ModelPath, digest string, regOpts *RegistryOptions, fn func
}
}
var
size
int64
var
size
int64
chunkSize
:=
1024
*
1024
// 1 MiB in bytes
fi
,
err
:=
os
.
Stat
(
fp
+
"-partial"
)
fi
,
err
:=
os
.
Stat
(
fp
+
"-partial"
)
switch
{
switch
{
...
@@ -922,6 +923,13 @@ func downloadBlob(mp ModelPath, digest string, regOpts *RegistryOptions, fn func
...
@@ -922,6 +923,13 @@ func downloadBlob(mp ModelPath, digest string, regOpts *RegistryOptions, fn func
return
fmt
.
Errorf
(
"stat: %w"
,
err
)
return
fmt
.
Errorf
(
"stat: %w"
,
err
)
default
:
default
:
size
=
fi
.
Size
()
size
=
fi
.
Size
()
// Ensure the size is divisible by the chunk size by removing excess bytes
size
-=
size
%
int64
(
chunkSize
)
err
:=
os
.
Truncate
(
fp
+
"-partial"
,
size
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"truncate: %w"
,
err
)
}
}
}
url
:=
fmt
.
Sprintf
(
"%s/v2/%s/blobs/%s"
,
mp
.
Registry
,
mp
.
GetNamespaceRepository
(),
digest
)
url
:=
fmt
.
Sprintf
(
"%s/v2/%s/blobs/%s"
,
mp
.
Registry
,
mp
.
GetNamespaceRepository
(),
digest
)
...
@@ -982,7 +990,7 @@ func downloadBlob(mp ModelPath, digest string, regOpts *RegistryOptions, fn func
...
@@ -982,7 +990,7 @@ func downloadBlob(mp ModelPath, digest string, regOpts *RegistryOptions, fn func
break
break
}
}
n
,
err
:=
io
.
CopyN
(
out
,
resp
.
Body
,
8192
)
n
,
err
:=
io
.
CopyN
(
out
,
resp
.
Body
,
int64
(
chunkSize
)
)
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
io
.
EOF
)
{
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
io
.
EOF
)
{
return
err
return
err
}
}
...
...
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