<commit_before>async = require('async')
fs = require('fs')
widgets = require('../widgets/widgets')
server = require('../../server/server')
ProgressBar = require('progress')

exports.remove = (name, confirmAttribute, deleteFunction, outerCallback) ->
	async.waterfall([

		(callback) ->
			if confirmAttribute
				return callback(null, true)

			widgets.confirmRemoval(name, callback)

		(confirmed, callback) ->
			return callback() if not confirmed
			deleteFunction(callback)

	], outerCallback)

exports.downloadFile = (url, dest, callback) ->
	bar = null
	received = 0

	server.request
		method: 'GET'
		url: url
		pipe: fs.createWriteStream(dest)
	, (error) ->
		return callback(error)
	, (state) ->

		bar ?= new ProgressBar 'Downloading device OS [:bar] :percent :etas',
			complete: '='
			incomplete: ' '
			width: 40
			total: state.total
<commit_msg>Add TODO regarding quieting progress bar<commit_after>async = require('async')
fs = require('fs')
widgets = require('../widgets/widgets')
server = require('../../server/server')
ProgressBar = require('progress')

exports.remove = (name, confirmAttribute, deleteFunction, outerCallback) ->
	async.waterfall([

		(callback) ->
			if confirmAttribute
				return callback(null, true)

			widgets.confirmRemoval(name, callback)

		(confirmed, callback) ->
			return callback() if not confirmed
			deleteFunction(callback)

	], outerCallback)

exports.downloadFile = (url, dest, callback) ->
	bar = null
	received = 0

	server.request
		method: 'GET'
		url: url
		pipe: fs.createWriteStream(dest)
	, (error) ->
		return callback(error)
	, (state) ->

		# TODO: Allow quieting this progress bar
		bar ?= new ProgressBar 'Downloading device OS [:bar] :percent :etas',
			complete: '='
			incomplete: ' '
			width: 40
			total: state.total

{'fraction_non_alphanumeric': 0.140625, 'fraction_numerical': 0.0033482142857142855, 'mean_word_length': 4.050704225352113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2476311', 'n_tokens_mistral': 621, 'n_tokens_neox': 537, 'n_words': 145}