Hi, On Thu, Apr 27, 2017 at 04:16:31PM -0500, Jonathon Jongsma wrote: > When transferring the same file multiple times, the vdagent tries to > avoid overwriting an existing file on the guest by appending an integer > to the filename. Instead of just appending the integer to the very end, > we now try to be smarter and append the integer before the file > extension. For example, if we transferred the file "file.doc" twice, the > second copy would have become "file.doc (1)". It is now "file (1).doc". > This matches more closely with the behavior of the Nautilus file manager > as well. > > Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx> > --- > src/vdagent/file-xfers.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/src/vdagent/file-xfers.c b/src/vdagent/file-xfers.c > index b3937a4..8fc33db 100644 > --- a/src/vdagent/file-xfers.c > +++ b/src/vdagent/file-xfers.c > @@ -202,7 +202,10 @@ void vdagent_file_xfers_start(struct vdagent_file_xfers *xfers, > path = g_strdup(file_path); > for (i = 0; i < 64 && (stat(path, &st) == 0 || errno != ENOENT); i++) { > g_free(path); > - path = g_strdup_printf("%s (%d)", file_path, i + 1); > + char *extension = strrchr(file_path, '.'); > + int basename_len = extension != NULL ? extension - file_path : -1; > + path = g_strdup_printf("%*s (%i)%s", basename_len, file_path, > + i + 1, extension ? extension : ""); I would add a small comment like "Adding an integer before the file extension" in this block. In the linux vdagent code, I don't see often variables being declared in the middle of the code block. Other than that, patch looks fine to me. > } > g_free(task->file_name); > task->file_name = path; > -- > 2.9.3 > > _______________________________________________ > Spice-devel mailing list > Spice-devel@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/spice-devel
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel