You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by gi...@git.apache.org on 2017/10/17 23:05:46 UTC
[GitHub] ccollins476ad closed pull request #100: newt - Don't corrupt project on failed install.
ccollins476ad closed pull request #100: newt - Don't corrupt project on failed install.
URL: https://github.com/apache/mynewt-newt/pull/100
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/newt/project/project.go b/newt/project/project.go
index 4fd9802..4d524a8 100644
--- a/newt/project/project.go
+++ b/newt/project/project.go
@@ -424,13 +424,15 @@ func (proj *Project) loadRepo(rname string, v *viper.Viper) error {
r.ReadDesc()
rvers := proj.projState.GetInstalledVersion(rname)
- code, msg := r.CheckNewtCompatibility(rvers, newtutil.NewtVersion)
- switch code {
- case compat.NEWT_COMPAT_GOOD:
- case compat.NEWT_COMPAT_WARN:
- util.StatusMessage(util.VERBOSITY_QUIET, "WARNING: %s.\n", msg)
- case compat.NEWT_COMPAT_ERROR:
- return util.NewNewtError(msg)
+ if rvers != nil {
+ code, msg := r.CheckNewtCompatibility(rvers, newtutil.NewtVersion)
+ switch code {
+ case compat.NEWT_COMPAT_GOOD:
+ case compat.NEWT_COMPAT_WARN:
+ util.StatusMessage(util.VERBOSITY_QUIET, "WARNING: %s.\n", msg)
+ case compat.NEWT_COMPAT_ERROR:
+ return util.NewNewtError(msg)
+ }
}
log.Debugf("Loaded repository %s (type: %s, user: %s, repo: %s)", rname,
diff --git a/newt/repo/repo.go b/newt/repo/repo.go
index 77cff0f..a39cd5f 100644
--- a/newt/repo/repo.go
+++ b/newt/repo/repo.go
@@ -651,30 +651,20 @@ func (r *Repo) UpdateDesc() ([]*Repo, bool, error) {
return repos, true, nil
}
-// Download the repository description.
-func (r *Repo) DownloadDesc() error {
+func (r *Repo) downloadRepositoryYml() error {
dl := r.downloader
+ dl.SetBranch("master")
- util.StatusMessage(util.VERBOSITY_VERBOSE, "Downloading "+
- "repository description\n")
-
- // Configuration path
cpath := r.repoFilePath()
- if util.NodeNotExist(cpath) {
- if err := os.MkdirAll(cpath, REPO_DEFAULT_PERMS); err != nil {
- return util.NewNewtError(err.Error())
- }
- }
-
- dl.SetBranch("master")
if err := dl.FetchFile(REPO_FILE_NAME,
cpath+"/"+REPO_FILE_NAME); err != nil {
util.StatusMessage(util.VERBOSITY_VERBOSE, "Download failed\n")
+
return err
}
// also create a directory to save diffs for sync
- cpath = r.patchesFilePath()
+ cpath = r.repoFilePath()
if util.NodeNotExist(cpath) {
if err := os.MkdirAll(cpath, REPO_DEFAULT_PERMS); err != nil {
return util.NewNewtError(err.Error())
@@ -682,6 +672,34 @@ func (r *Repo) DownloadDesc() error {
}
util.StatusMessage(util.VERBOSITY_VERBOSE, "Download successful!\n")
+ return nil
+}
+
+// Download the repository description.
+func (r *Repo) DownloadDesc() error {
+ util.StatusMessage(util.VERBOSITY_VERBOSE, "Downloading "+
+ "repository description\n")
+
+ // Remember if the directory already exists. If it doesn't, we'll create
+ // it. If downloading fails, only remove the directory if we just created
+ // it.
+ createdDir := false
+
+ // Configuration path
+ cpath := r.repoFilePath()
+ if util.NodeNotExist(cpath) {
+ if err := os.MkdirAll(cpath, REPO_DEFAULT_PERMS); err != nil {
+ return util.NewNewtError(err.Error())
+ }
+ createdDir = true
+ }
+
+ if err := r.downloadRepositoryYml(); err != nil {
+ if createdDir {
+ os.RemoveAll(cpath)
+ }
+ return err
+ }
return nil
}
diff --git a/newt/resolve/resolve.go b/newt/resolve/resolve.go
index c037443..0ecf9ed 100644
--- a/newt/resolve/resolve.go
+++ b/newt/resolve/resolve.go
@@ -143,7 +143,7 @@ func (r *Resolver) resolveDep(dep *pkg.Dependency, depender string) (*pkg.LocalP
return lpkg, nil
}
-// @return true if rhe package's dependency list was
+// @return true if the package's dependency list was
// modified.
func (rpkg *ResolvePackage) AddDep(apiPkg *ResolvePackage, api string) bool {
if dep := rpkg.Deps[apiPkg]; dep != nil {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services