Closed MSevey closed 6 years ago
add endpoint to clear before and clear after
change download history back to slice and use binary search
Need to update documentation
If the intent is to use StartTimeUnix
as a unique identifier, I would rather just add an explicit ID. Something like:
func (d DownloadInfo) ID() string {
hashStr := crypto.HashAll(
d.Destination,
d.Length,
d.Offset,
d.SiaPath,
d.StartTime,
).String()
return hashStr[:12]
}
@lukechampine i used the unix timestamp as a unique identifier and then also as the parameter for the binary search. Can I do a binary search on a hash?
oh, I missed that we were clearing all of the downloads before/after a given timestamp. A hash wouldn't work for that. Although, is this functionality that we need to implement on the backend? It wouldn't be hard for the UI to loop over the downloads, get the ID of each download it wants to clear, and then make a separate request for each ID. (If separate requests are too expensive, we can accept a list of IDs.) I prefer to keep the API flexible so that you can do things like "delete all downloads containing the string 'foo'."
@lukechampine we could make that a future update, if we wanted the UI to handle the different deletion requests and send them to a single API endpoint and we make that endpoint flexible enough to handle the different requests.
If we did that it would go back to my original plan where I created a map for the Download history and we could use the Hash ID as the key. Then the UI could just send lists of the IDs to the single endpoint that just removes them from the map.
Let me know if you'd like me to: A) Submit an issue for a future feature request on the UI to handle the different clear history request and leave this PR as is or B) Set up the API now where we have 1 endpoint to clear the entire history, and 1 endpoint that takes a slice of IDs and removes them from the download histroy
Option B I would still have to submit a feature request for the UI that it adds the functionality send a history deletion request
As discussed, I will make the following changes:
1) Simplify down to 1 API endpoint that takes a range of times. 2) API will handle blanks input from the user, valid API calls are the following
/renter/downloads/clear
/renter/downloads/clear?start=today
/renter/downloads/clear?end=today
/renter/downloads/clear?start=yesterday&end=today
/renter/downloads/clear?start=yesterday&end=yesterday
These correspond to:
Looks good to me.
Added methods to clear the entire download history for the renter and remove specific downloads from the download history. Both methods are accessible through the API.
resolves #3068