Browse Source

fix code style

deepak1556 8 years ago
parent
commit
5d94221c61
2 changed files with 10 additions and 2 deletions
  1. 9 1
      atom/browser/api/atom_api_session.cc
  2. 1 1
      spec/api-session-spec.js

+ 9 - 1
atom/browser/api/atom_api_session.cc

@@ -554,8 +554,16 @@ void Session::CreateInterruptedDownload(const mate::Dictionary& options) {
   options.Get("lastModified", &last_modified);
   options.Get("eTag", &etag);
   options.Get("startTime", &start_time);
-  if (path.empty() || url_chain.empty() || length == 0 || offset >= length)
+  if (path.empty() || url_chain.empty() || length == 0) {
+    isolate()->ThrowException(v8::Exception::Error(mate::StringToV8(
+        isolate(), "Must pass non-empty path, urlChain and length.")));
     return;
+  }
+  if (offset >= length) {
+    isolate()->ThrowException(v8::Exception::Error(mate::StringToV8(
+        isolate(), "Must pass an offset value less than length.")));
+    return;
+  }
   auto download_manager =
       content::BrowserContext::GetDownloadManager(browser_context());
   download_manager->GetDelegate()->GetNextId(base::Bind(

+ 1 - 1
spec/api-session-spec.js

@@ -601,7 +601,7 @@ describe('session module', function () {
                                                      totalBytes, filename,
                                                      savePath) {
         assert.equal(state, 'interrupted')
-        assert.equal(urlChain, urlChain)
+        assert.deepEqual(urlChain, urlChain)
         assert.equal(mimeType, 'application/pdf')
         assert.equal(receivedBytes, 0)
         assert.equal(totalBytes, 5242880)