<commit_before># = require uploadcare/utils/pusher

{
  namespace,
  jQuery: $,
  utils
} = uploadcare
{pusher} = uploadcare.utils

namespace 'uploadcare.files', (ns) ->

  class ns.UrlFile extends ns.BaseFile
    allEvents: 'progress success error fail'

    constructor: (settings, @__url) ->
      super

      filename = utils.splitUrlRegex.exec(@__url)[3].split('/').pop()
      if filename
        try
          @fileName = decodeURIComponent(filename)
        catch err
          @fileName = filename

      @__notifyApi()

    setName: (@fileName) ->
      @__realFileName = fileName
      @__notifyApi()

    setIsImage: (@isImage) ->
      @__notifyApi()

    setSourceInfo: (@sourceInfo) ->
      @__notifyApi()

    __startUpload: ->
      df = $.Deferred()
      pusherWatcher = new PusherWatcher(@settings.pusherKey)
      pollWatcher = new PollWatcher("#{@settings.urlBase}/status/")
      @__listenWatcher(df, $([pusherWatcher, pollWatcher]))

      # turn off pollWatcher if we receive any message from pusher
      $(pusherWatcher).one @allEvents, =>
        pollWatcher.stopWatching()

      data =
        pub_key: @settings.publicKey
        source_url: @__url
        filename: @__realFileName or ''
        store: if @settings.doNotStore then '' else 'auto'<commit_msg>use not deprecated endpoint from_url/status<commit_after># = require uploadcare/utils/pusher

{
  namespace,
  jQuery: $,
  utils
} = uploadcare
{pusher} = uploadcare.utils

namespace 'uploadcare.files', (ns) ->

  class ns.UrlFile extends ns.BaseFile
    allEvents: 'progress success error fail'

    constructor: (settings, @__url) ->
      super

      filename = utils.splitUrlRegex.exec(@__url)[3].split('/').pop()
      if filename
        try
          @fileName = decodeURIComponent(filename)
        catch err
          @fileName = filename

      @__notifyApi()

    setName: (@fileName) ->
      @__realFileName = fileName
      @__notifyApi()

    setIsImage: (@isImage) ->
      @__notifyApi()

    setSourceInfo: (@sourceInfo) ->
      @__notifyApi()

    __startUpload: ->
      df = $.Deferred()
      pusherWatcher = new PusherWatcher(@settings.pusherKey)
      pollWatcher = new PollWatcher("#{@settings.urlBase}/from_url/status/")
      @__listenWatcher(df, $([pusherWatcher, pollWatcher]))

      # turn off pollWatcher if we receive any message from pusher
      $(pusherWatcher).one @allEvents, =>
        pollWatcher.stopWatching()

      data =
        pub_key: @settings.publicKey
        source_url: @__url
        filename: @__realFileName or ''
        store: if @settings.doNotStore then '' else 'auto'
{'fraction_non_alphanumeric': 0.12047274113610369, 'fraction_numerical': 0.0007624857033930614, 'mean_word_length': 2.7539341917024323, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3222067', 'n_tokens_mistral': 800, 'n_tokens_neox': 806, 'n_words': 177}