Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
liber
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ale
liber
Commits
449c44bc
Commit
449c44bc
authored
9 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
recover from panic in metadata extraction
parent
37aff84a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
metadata.go
+11
-8
11 additions, 8 deletions
metadata.go
with
11 additions
and
8 deletions
metadata.go
+
11
−
8
View file @
449c44bc
...
...
@@ -245,10 +245,16 @@ func parseAnything(filename string) (*Metadata, error) {
type
fileProvider
struct
{}
func
(
p
*
fileProvider
)
Lookup
(
storage
*
FileStorage
,
path
,
filetype
string
)
(
*
Metadata
,
error
)
{
func
(
p
*
fileProvider
)
Lookup
(
storage
*
FileStorage
,
path
,
filetype
string
)
(
m
*
Metadata
,
err
error
)
{
// Catch panics from some of the underlying libraries (gmobi
// in particular) and transform them into errors.
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
err
=
fmt
.
Errorf
(
"panic(): %v"
,
r
.
(
error
))
}
}()
path
=
storage
.
Abs
(
path
)
var
m
*
Metadata
var
err
error
switch
filetype
{
case
".epub"
:
m
,
err
=
parseEpub
(
path
)
...
...
@@ -257,13 +263,10 @@ func (p *fileProvider) Lookup(storage *FileStorage, path, filetype string) (*Met
case
".pdf"
:
m
,
err
=
parseAnything
(
path
)
default
:
return
nil
,
errors
.
New
(
"unsupported file format"
)
}
if
err
!=
nil
{
return
nil
,
err
err
=
errors
.
New
(
"unsupported file format"
)
}
return
m
,
nil
return
}
func
(
p
*
fileProvider
)
GetBookCover
(
storage
*
FileStorage
,
path
string
)
(
string
,
error
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment