Skip to content

Multiple fetch calls result in unnecessary downloads #5

@akshaybadola

Description

@akshaybadola

Sometimes a pdf file takes a long time to download and as a consequence a user can call it again. That results in redundancy as a PDF file is then downloaded again needlessly. There needs to be flag with a timeout which checks if the last call is finished and a way for the user to abort the download also.

  • We can do with a progress meter of download but I'm not sure if that's supported by url-retrieve.

  • So upon a quick search, there's a make-progress-reporter and progress-reporter update function which can be used

    (defun show-progress-demo ()
      (interactive)
      (let ((download-reporter
             (make-progress-reporter "Downloading python documentation..."
                                     0  100)))
        (url-retrieve "http://www.google.com"
                      (lambda (data bar)
                        ;; skip http header
                        (re-search-forward "\r?\n\r?\n")
                        (write-region (point) (point-max) "/tmp/google")
                        (progress-reporter-done bar))
                        `(,download-reporter))
        (dotimes (k 100)
          (sit-for 0.01)
          (progress-reporter-update download-reporter k))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions