UploadedFile should include the file extension in its url
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2017 04:43:00 +0000 (04:43 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2017 04:43:00 +0000 (04:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174009

Reviewed by Chris Dumez.

Some command line tools such as darwinup use the file extension to determine the file type.
Include the file extension in the URL of an uploaded file to make it work with these tools.

* public/include/uploaded-file-helpers.php:
(format_uploaded_file): Include the file extension.
* public/v3/models/uploaded-file.js:
(UploadedFile):
(UploadedFile.prototype.url): Return the URL with hthe file extension specified. /api/uploaded-file
already supports having the file extension specified.
* server-tests/tools-sync-buildbot-integration-tests.js: Updated test cases.
* unit-tests/buildbot-syncer-tests.js: Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218987 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/public/include/uploaded-file-helpers.php
Websites/perf.webkit.org/public/v3/models/uploaded-file.js
Websites/perf.webkit.org/server-tests/tools-sync-buildbot-integration-tests.js
Websites/perf.webkit.org/unit-tests/buildbot-syncer-tests.js

index 9dd8f23..298bdef 100644 (file)
@@ -1,3 +1,22 @@
+2017-06-29  Ryosuke Niwa  <rniwa@webkit.org>
+
+        UploadedFile should include the file extension in its url
+        https://bugs.webkit.org/show_bug.cgi?id=174009
+
+        Reviewed by Chris Dumez.
+
+        Some command line tools such as darwinup use the file extension to determine the file type.
+        Include the file extension in the URL of an uploaded file to make it work with these tools.
+
+        * public/include/uploaded-file-helpers.php:
+        (format_uploaded_file): Include the file extension.
+        * public/v3/models/uploaded-file.js:
+        (UploadedFile):
+        (UploadedFile.prototype.url): Return the URL with hthe file extension specified. /api/uploaded-file
+        already supports having the file extension specified.
+        * server-tests/tools-sync-buildbot-integration-tests.js: Updated test cases.
+        * unit-tests/buildbot-syncer-tests.js: Ditto.
+
 2017-05-31  Ryosuke Niwa  <rniwa@webkit.org>
 
         Don't shouldn't create a request to build a patch if there is no patch to build
index 47a7bac..34341c2 100644 (file)
@@ -10,6 +10,7 @@ function format_uploaded_file($file_row)
         'createdAt' => Database::to_js_time($file_row['file_created_at']),
         'mime' => $file_row['file_mime'],
         'filename' => $file_row['file_filename'],
+        'extension' => $file_row['file_extension'],
         'author' => $file_row['file_author'],
         'sha256' => $file_row['file_sha256']);
 }
index 4fdf347..bea35d3 100644 (file)
@@ -7,6 +7,7 @@ class UploadedFile extends DataModelObject {
         this._createdAt = new Date(object.createdAt);
         this._deletedAt = object.deletedAt ? new Date(object.deletedAt) : null;
         this._filename = object.filename;
+        this._extension = object.extension;
         this._author = object.author;
         this._size = object.size;
         this._sha256 = object.sha256;
@@ -19,7 +20,7 @@ class UploadedFile extends DataModelObject {
     author() { return this._author; }
     size() { return this._size; }
     label() { return this.filename(); }
-    url() { return RemoteAPI.url(`/api/uploaded-file/${this.id()}`); }
+    url() { return RemoteAPI.url(`/api/uploaded-file/${this.id()}${this._extension}`); }
 
     static uploadFile(file, uploadProgressCallback = null)
     {
index 773195e..dbe2d80 100644 (file)
@@ -173,7 +173,7 @@ describe('sync-buildbot', function () {
         }).then(() => {
             assert.equal(requests.length, 7);
             assertAndResolveRequest(requests[6], 'POST', '/builders/some%20builder/force', 'OK');
-            assert.deepEqual(requests[6].data, {'wk': '191622', 'wk-patch': RemoteAPI.url('/api/uploaded-file/1'),
+            assert.deepEqual(requests[6].data, {'wk': '191622', 'wk-patch': RemoteAPI.url('/api/uploaded-file/1.dat'),
                 'build-request-id': '1', 'forcescheduler': 'force-ab-builds'});
             return MockRemoteAPI.waitForRequest();
         }).then(() => {
index 6991ebf..f0d125e 100644 (file)
@@ -229,10 +229,10 @@ function createSampleBuildRequestWithPatch(platform, test, order)
     const shared111237 = CommitLog.ensureSingleton('111237', {'id': '111237', 'time': 1456931874000, 'repository': MockModels.sharedRepository, 'revision': '80229'});
     const ios13A452 = CommitLog.ensureSingleton('88930', {'id': '88930', 'time': 0, 'repository': MockModels.ios, 'revision': '13A452'});
 
-    const patch = new UploadedFile(453, {'createdAt': new Date('2017-05-01T19:16:53Z'), 'filename': 'patch.dat', 'author': 'some user',
+    const patch = new UploadedFile(453, {'createdAt': new Date('2017-05-01T19:16:53Z'), 'filename': 'patch.dat', 'extension': '.dat', 'author': 'some user',
         size: 534637, sha256: '169463c8125e07c577110fe144ecd63942eb9472d438fc0014f474245e5df8a1'});
 
-    const root = new UploadedFile(456, {'createdAt': new Date('2017-05-01T21:03:27Z'), 'filename': 'root.dat', 'author': 'some user',
+    const root = new UploadedFile(456, {'createdAt': new Date('2017-05-01T21:03:27Z'), 'filename': 'root.dat', 'extension': '.dat', 'author': 'some user',
         size: 16452234, sha256: '03eed7a8494ab8794c44b7d4308e55448fc56f4d6c175809ba968f78f656d58d'});
 
     const commitSet = CommitSet.ensureSingleton('53246456', {customRoots: [root], revisionItems: [{commit: webkit197463, patch}, {commit: shared111237}, {commit: ios13A452}]});
@@ -975,7 +975,7 @@ describe('BuildbotSyncer', () => {
             const request = createSampleBuildRequestWithPatch(MockModels.iphone, null, -1);
             const properties = syncers[2]._propertiesForBuildRequest(request, [request]);
             assert.equal(properties['webkit'], '197463');
-            assert.equal(properties['webkit-patch'], 'http://build.webkit.org/api/uploaded-file/453');
+            assert.equal(properties['webkit-patch'], 'http://build.webkit.org/api/uploaded-file/453.dat');
         });
 
         it('should resolve "ifBuilt"', () => {
@@ -996,16 +996,16 @@ describe('BuildbotSyncer', () => {
             const requestToBuild = createSampleBuildRequestWithPatch(MockModels.iphone, null, -1);
             const requestToTest = createSampleBuildRequestWithPatch(MockModels.iphone, MockModels.speedometer, 0);
             const otherRequestToTest = createSampleBuildRequest(MockModels.iphone, MockModels.speedometer);
-    
+
             let properties = syncers[0]._propertiesForBuildRequest(requestToTest, [requestToTest]);
             assert.equal(properties['webkit'], '197463');
-            assert.equal(properties['roots'], '[{"url":"http://build.webkit.org/api/uploaded-file/456"}]');
+            assert.equal(properties['roots'], '[{"url":"http://build.webkit.org/api/uploaded-file/456.dat"}]');
             assert.equal(properties['test-custom-build'], undefined);
             assert.equal(properties['has-built-patch'], undefined);
 
             properties = syncers[0]._propertiesForBuildRequest(requestToTest, [requestToBuild, requestToTest]);
             assert.equal(properties['webkit'], '197463');
-            assert.equal(properties['roots'], '[{"url":"http://build.webkit.org/api/uploaded-file/456"}]');
+            assert.equal(properties['roots'], '[{"url":"http://build.webkit.org/api/uploaded-file/456.dat"}]');
             assert.equal(properties['test-custom-build'], '');
             assert.equal(properties['has-built-patch'], 'true');