// asset.DownloadURL maybe a local file
var rc io.ReadCloser
var err error
- if asset.DownloadURL == nil {
+ if asset.DownloadFunc != nil {
rc, err = asset.DownloadFunc()
if err != nil {
return err
}
- } else {
+ } else if asset.DownloadURL != nil {
rc, err = uri.Open(*asset.DownloadURL)
if err != nil {
return err
}
}
- defer rc.Close()
+ if rc == nil {
+ return nil
+ }
_, err = storage.Attachments.Save(attach.RelativePath(), rc, int64(*asset.Size))
+ rc.Close()
return err
}()
if err != nil {
return err
}
- log.Trace("migrating git data")
+ log.Trace("migrating git data from %s", repo.CloneURL)
if err = uploader.CreateRepo(repo, opts); err != nil {
return err
}
IsPrivate: isPrivate,
Description: opts["description"],
OriginalURL: opts["original_url"],
- CloneURL: opts["clone_addr"],
+ CloneURL: filepath.Join(r.baseDir, "git"),
DefaultBranch: opts["default_branch"],
}, nil
}
}
for _, rel := range releases {
for _, asset := range rel.Assets {
- *asset.DownloadURL = "file://" + filepath.Join(r.baseDir, *asset.DownloadURL)
+ if asset.DownloadURL != nil {
+ *asset.DownloadURL = "file://" + filepath.Join(r.baseDir, *asset.DownloadURL)
+ }
}
}
return releases, nil