Update to be compatible with Go r60.3
authorRobert Sesek <rsesek@bluestatic.org>
Fri, 30 Dec 2011 15:27:12 +0000 (10:27 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Fri, 30 Dec 2011 15:27:12 +0000 (10:27 -0500)
build.py
src/server.go
src/tv_rename.go

index ceacb9c76cfbea5bad599942f42796c06685ac59..74acfd34b8cd5148e73fa0bcd436c0b2ec3ce338 100755 (executable)
--- a/build.py
+++ b/build.py
@@ -51,7 +51,7 @@ RESOURCES_FE = [
 PRODUCT_NAME = 'armadillo'
 
 # The Golang version (hg id).
-BACK_END_COMPILER_VERSION = '95d2ce135523 (release-branch.r57) release/release.r57.1'
+BACK_END_COMPILER_VERSION = 'c1702f36df03 (release-branch.r60) release/release.r60.3'
 
 COMPILER = '6g'
 LINKER = '6l'
index d050b42b0e8eb2735aa40acbe03d8dcfb27e7eaf..2b6f500d8604398dabdd993e63ce14c735135d27 100644 (file)
@@ -18,6 +18,7 @@ import (
        "os"
        "path"
        "strings"
+       "url"
        "./config"
        "./paths"
        "./tv_rename"
@@ -80,7 +81,7 @@ func serviceHandler(response http.ResponseWriter, request *http.Request) {
                        errorResponse(response, err.String())
                } else {
                        data := map[string]interface{}{
-                               "path": path,
+                               "path":  path,
                                "error": 0,
                        }
                        okResponse(response, data)
@@ -119,27 +120,27 @@ func proxyHandler(response http.ResponseWriter, request *http.Request) {
                return
        }
 
-       url, err := http.ParseURL(rawURL)
+       url_, err := url.Parse(rawURL)
        if err != nil {
                errorResponse(response, err.String())
                return
        }
-       err = performProxy(url, response, request)
+       err = performProxy(url_, response, request)
        if err != nil {
                errorResponse(response, err.String())
        }
 }
 
-func performProxy(url *http.URL, response http.ResponseWriter, origRequest *http.Request) os.Error {
-       conn, err := net.Dial("tcp", url.Host+":http")
+func performProxy(url_ *url.URL, response http.ResponseWriter, origRequest *http.Request) os.Error {
+       conn, err := net.Dial("tcp", url_.Host+":http")
        if err != nil {
                return err
        }
        client := http.NewClientConn(conn, nil)
        var request http.Request
-       request.URL = url
+       request.URL = url_
        request.Method = "GET"
-       request.UserAgent = origRequest.UserAgent
+       request.Header.Set("User-Agent", origRequest.UserAgent())
        err = client.Write(&request)
        if err != nil {
                return err
@@ -156,7 +157,7 @@ func performProxy(url *http.URL, response http.ResponseWriter, origRequest *http
 func downloadHandler(response http.ResponseWriter, request *http.Request) {
        valid, fullPath := paths.IsValid(request.FormValue("path"))
        if valid {
-               info, _ := os.Lstat(fullPath)  // Error is already checked by |valid|.
+               info, _ := os.Lstat(fullPath) // Error is already checked by |valid|.
                if info.IsDirectory() {
                        http.Error(response, "Path is a directory", http.StatusBadRequest)
                } else {
@@ -196,7 +197,7 @@ func okResponse(response http.ResponseWriter, data interface{}) {
 func RunBackEnd(config *config.Configuration) {
        mux := http.NewServeMux()
        mux.HandleFunc("/", indexHandler)
-       mux.Handle("/fe/", http.FileServer(kFrontEndFiles, "/fe/"))
+       mux.Handle("/fe/", http.StripPrefix("/fe/", http.FileServer(http.Dir(kFrontEndFiles))))
        mux.HandleFunc("/service", serviceHandler)
        mux.HandleFunc("/download", downloadHandler)
        mux.HandleFunc("/proxy", proxyHandler)
index 4f003be2813aae507f01d6f0cb2087b2bd1ab751..9d0eeabfacc163471a258d792170c331ae00577c 100644 (file)
@@ -19,6 +19,7 @@ import (
        "regexp"
        "strconv"
        "strings"
+       "url"
 )
 
 // Takes a full file path and renames the last path component as if it were a
@@ -94,7 +95,7 @@ func parseEpisodeName(name string) *episodeInfo {
 // Builds the URL to which we send a HTTP request to get the episode name.
 func buildURL(info *episodeInfo) string {
        return fmt.Sprintf("http://services.tvrage.com/tools/quickinfo.php?show=%s&ep=%dx%d",
-               http.URLEscape(info.showName), info.season, info.episode)
+               url.QueryEscape(info.showName), info.season, info.episode)
 }
 
 // Converts a season and episode to integers. If the return values are both 0,
@@ -113,13 +114,13 @@ func convertEpisode(season string, episode string) (int, int) {
 
 // Performs the actual lookup and returns the HTTP response.
 func performLookup(urlString string) (*http.Response, os.Error) {
-       url, err := http.ParseURL(urlString)
+       url_, err := url.Parse(urlString)
        if err != nil {
                return nil, err
        }
 
        // Open a TCP connection.
-       conn, err := net.Dial("tcp", url.Host+":"+url.Scheme)
+       conn, err := net.Dial("tcp", url_.Host+":"+url_.Scheme)
        if err != nil {
                return nil, err
        }
@@ -127,9 +128,9 @@ func performLookup(urlString string) (*http.Response, os.Error) {
        // Perform the HTTP request.
        client := http.NewClientConn(conn, nil)
        var request http.Request
-       request.URL = url
+       request.URL = url_
        request.Method = "GET"
-       request.UserAgent = "Armadillo File Manager"
+       request.Header.Set("User-Agent", "Armadillo File Manager")
        err = client.Write(&request)
        if err != nil {
                return nil, err
@@ -149,7 +150,7 @@ func parseResponse(response *http.Response) *fullEpisodeInfo {
                if err != nil {
                        return nil
                }
-               var parts []string = strings.Split(line, "@", 2)
+               var parts []string = strings.SplitN(line, "@", 2)
                if len(parts) != 2 {
                        continue
                }
@@ -158,10 +159,10 @@ func parseResponse(response *http.Response) *fullEpisodeInfo {
                        info.episode.showName = strings.TrimSpace(parts[1])
                case "Episode Info":
                        // Split the line, which is of the form: |SxE^Name^AirDate|.
-                       parts = strings.Split(parts[1], "^", 3)
+                       parts = strings.SplitN(parts[1], "^", 3)
                        info.episodeName = parts[1]
                        // Split the episode string.
-                       episode := strings.Split(parts[0], "x", 2)
+                       episode := strings.SplitN(parts[0], "x", 2)
                        info.episode.season, info.episode.episode = convertEpisode(episode[0], episode[1])
                        if info.episode.season == 0 && info.episode.season == info.episode.episode {
                                return nil