Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUACAMOLE-1536: return file size and file permission information when uploading files and displaying file directories #754

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

iamsee
Copy link

@iamsee iamsee commented Aug 12, 2022

zhangys36 and others added 2 commits August 12, 2022 16:01
… uploading files and displaying file directories
GUACAMOLE-1536: return file size and file permission information when…
Comment on lines +358 to +366
var Ow_R = 256;
var Ow_W = 128;
var Ow_X = 64;
var Gp_R = 32;
var Gp_W = 16;
var Gp_X = 8;
var Ot_R = 4;
var Ot_W = 2;
var Ot_X = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. These should be defined (and documented) as constants: https://guacamole.apache.org/guac-style/#comments-and-documentation
  2. These should be named according to constant naming convention (UPPERCASE_WITH_UNDERSCORES): https://guacamole.apache.org/guac-style/#naming

Comment on lines +368 to +413
let res = '';
if ((permission & Ow_R) === Ow_R) {
res += 'r';
} else {
res += '-';
}
if ((permission & Ow_W) === Ow_W) {
res += 'w';
} else {
res += '-';
}
if ((permission & Ow_X) === Ow_X) {
res += 'x';
} else {
res += '-';
}
if ((permission & Gp_R) === Gp_R) {
res += 'r';
} else {
res += '-';
}
if ((permission & Gp_W) === Gp_W) {
res += 'w';
} else {
res += '-';
}
if ((permission & Gp_X) === Gp_X) {
res += 'x';
} else {
res += '-';
}
if ((permission & Ot_R) === Ot_R) {
res += 'r';
} else {
res += '-';
}
if ((permission & Ot_W) === Ot_W) {
res += 'w';
} else {
res += '-';
}
if ((permission & Ot_X) === Ot_X) {
res += 'x';
} else {
res += '-';
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's got to be a more readable way to do this. Perhaps you can structure things as a loop and avoid this kind of brute-force list?

Comment on lines +150 to +161
// try deserialization fileJSON String to fileObject
var size = 0;
var permission = null;
try {
var fileObj = JSON.parse(mimetypes[name])
size = fileObj.size || 0;
if (fileObj.perm) {
permission = ManagedFilesystem.permissionTranslate(fileObj.perm);
}
} catch (e) {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? These values do not appear to be used anywhere.

permission = ManagedFilesystem.permissionTranslate(fileObj.perm);
}
} catch (e) {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? $evalAsync() is not documented as doing anything with the return value of the provided callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants