From f6baa172a545ca8aa4e50895a033b0b0b424e032 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 29 Jan 2013 04:17:17 +0100 Subject: [PATCH] Fetch archived logs from S3 without redirect --- assets/scripts/app/models/artifact.coffee | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/assets/scripts/app/models/artifact.coffee b/assets/scripts/app/models/artifact.coffee index 091f86d5..bb46dcf6 100644 --- a/assets/scripts/app/models/artifact.coffee +++ b/assets/scripts/app/models/artifact.coffee @@ -22,12 +22,23 @@ require 'travis/model' fetchBody: -> self = this - Travis.ajax.ajax "/jobs/#{@get('job.id')}/log.txt", 'GET', + Travis.ajax.ajax "/jobs/#{@get('job.id')}/log.txt?cors_hax=true", 'GET', dataType: 'text' contentType: 'text/plain' - success: (data) -> - self.set 'body', data - self.set 'isLoaded', true + success: (data, textStatus, xhr) -> + if xhr.status == 204 + logUrl = xhr.getResponseHeader('Location') + $.ajax + url: logUrl + type: 'GET' + success: (data) -> + self.fetchedBody(data) + else + self.fetchedBody(data) + + fetchedBody: (body) -> + @set 'body', body + @set 'isLoaded', true append: (body) -> if @get('isInitialized')