diff --git a/.drone.yml b/.drone.yml index 4f54bff..af239d2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -26,7 +26,7 @@ steps: secret_key: from_secret: MINIO_SECRET_KEY endpoint: https://minio.burble.dn42 - region: uk-lon3 + region: fr-par1 path_style: true source: dn42regsrv target: /dn42regsrv/${DRONE_BRANCH} @@ -40,7 +40,7 @@ steps: secret_key: from_secret: MINIO_SECRET_KEY endpoint: https://minio.burble.dn42 - region: uk-lon3 + region: fr-par1 path_style: true source: staticroot.tar.gz target: /dn42regsrv/${DRONE_BRANCH} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3b2e2c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,68 @@ +# ---> Go +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# ---> Emacs +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +# network security +/network-security.data + +dn42regsrv diff --git a/registry.go b/registry.go index 8aed9dd..dad0751 100644 --- a/registry.go +++ b/registry.go @@ -348,56 +348,59 @@ func loadAttributes(path string) []*RegAttribute { line := strings.TrimRight(scanner.Text(), "\r\n") + // skip empty lines + if len(line) == 0 { + continue + } + // lines starting with '+' denote an empty line if line[0] == '+' { - // concatenate a \n on to the previous attribute value attributes[len(attributes)-1].RawValue += "\n" + continue + } - } else { + // look for a : separator in the first 20 characters + ix := strings.IndexByte(line, ':') + if ix == -1 || ix >= 20 { + // couldn't find one - // look for a : separator in the first 20 characters - ix := strings.IndexByte(line, ':') - if ix == -1 || ix >= 20 { - // couldn't find one + if len(line) <= 20 { + // hmmm, the line was shorter than 20 characters + // something is amiss - if len(line) <= 20 { - // hmmm, the line was shorter than 20 characters - // something is amiss + log.WithFields(log.Fields{ + "length": len(line), + "path": path, + "line": line, + }).Warn("Short line detected") - log.WithFields(log.Fields{ - "length": len(line), - "path": path, - "line": line, - }).Warn("Short line detected") - - } else { - - // line is a continuation of the previous line, so - // concatenate the value on to the previous attribute value - attributes[len(attributes)-1].RawValue += - "\n" + string(line[20:]) - - } } else { - // found a key and : separator - // is there actually a value ? - var value string - if len(line) <= 20 { - // blank value - value = "" - } else { - value = string(line[20:]) - } + // line is a continuation of the previous line, so + // concatenate the value on to the previous attribute value + attributes[len(attributes)-1].RawValue += + "\n" + string(line[20:]) - // create a new attribute - a := &RegAttribute{ - Key: string(line[:ix]), - RawValue: value, - } - attributes = append(attributes, a) } + } else { + // found a key and : separator + + // is there actually a value ? + var value string + if len(line) <= 20 { + // blank value + value = "" + } else { + value = string(line[20:]) + } + + // create a new attribute + a := &RegAttribute{ + Key: string(line[:ix]), + RawValue: value, + } + attributes = append(attributes, a) } }