Graphics protocol: Clear any partially uploaded data for a chunked load when any delete command is received

Fixes #7968
This commit is contained in:
Kovid Goyal 2024-10-13 09:49:44 +05:30
parent b07d4059d3
commit 70d72b22d8
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 15 additions and 0 deletions

View file

@ -754,6 +754,9 @@ deleted, if the capital letter form above is specified. Also, when the terminal
is running out of quota space for new images, existing images without
placements will be preferentially deleted.
If an image is being loaded in chunks and the upload is not complete when any
delete command is received, the partial upload must be aborted.
Some examples::
<ESC>_Ga=d<ESC>\ # delete all visible placements

View file

@ -2096,6 +2096,7 @@ point3d_filter_func(const ImageRef *ref, Image *img, const void *data, CellPixel
static void
handle_delete_command(GraphicsManager *self, const GraphicsCommand *g, Cursor *c, bool *is_dirty, CellPixelSize cell) {
if (self->currently_loading.loading_for.image_id) free_load_data(&self->currently_loading);
GraphicsCommand d;
bool only_first_image = false;
switch (g->delete_action) {

View file

@ -410,6 +410,17 @@ def test_load_images(self):
img = g.image_for_client_id(1)
self.ae(img['data'], b'abcdefghijklmnop')
# Test interrupted and retried chunked load
self.assertIsNone(pl('abcd', s=2, v=2, m=1))
self.assertIsNone(pl('efgh', m=1))
send_command(s, 'a=d') # delete command should clear partial transfer
self.assertIsNone(pl('abcd', s=2, v=2, m=1))
self.assertIsNone(pl('efgh', m=1))
self.assertIsNone(pl('ijkl', m=1))
self.ae(pl('1234', m=0), 'OK')
img = g.image_for_client_id(1)
self.ae(img['data'], b'abcdefghijkl1234')
random_data = byte_block(32 * 1024)
sl(
random_data,