bookread-he commented on code in PR #367:
URL: https://github.com/apache/guacamole-server/pull/367#discussion_r1409042360
##########
src/common-ssh/sftp.c:
##########
@@ -653,10 +654,19 @@ static int guac_common_ssh_sftp_ls_ack_handler(guac_user*
user,
/* Determine mimetype */
const char* mimetype;
- if (LIBSSH2_SFTP_S_ISDIR(attributes.permissions))
- mimetype = GUAC_USER_STREAM_INDEX_MIMETYPE;
- else
- mimetype = "application/octet-stream";
+ //adding file size and permission
+ char tmpstr[150];
+ if (LIBSSH2_SFTP_S_ISDIR(attributes.permissions)) {
+ sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%llu,\"perm\":%lu}",
+ GUAC_USER_STREAM_INDEX_MIMETYPE, attributes.filesize,
+ attributes.permissions);
+ }
+ else {
+ sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%llu,\"perm\":%lu}",
+ "application/octet-stream", attributes.filesize,
+ attributes.permissions);
+ }
+ mimetype = tmpstr;
Review Comment:
Hello Mike,
I hope you're doing well. It's been some time since our last interaction,
and I've taken this period to carefully consider and implement the MIME type
encoding approach you recommended for the project.
With your guidance in mind, I've crafted a string that incorporates the
additional file attributes as MIME type parameters, ensuring that the original
distinction between files and directories is maintained. Here's the updated
code snippet:
```c
char property_value[256];
snprintf(property_value, sizeof(property_value),
"%s;size=%llu;mode=%o;uid=%d;gid=%d",
mimetype,
(unsigned long long) attributes.filesize,
attributes.permissions & 07777,
attributes.uid,
attributes.gid);
guac_common_json_write_property(user, stream, &list_state->json_state,
absolute_path, property_value);
```
I would be grateful for your feedback on this revision. Does this change
correctly reflect the format you envisioned? Your further input would be
incredibly valuable.
Thank you for your guidance and patience.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]