-
Notifications
You must be signed in to change notification settings - Fork 712
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ angular.module('client').factory('ManagedFilesystem', ['$rootScope', '$injector' | |
* Object which serves as a surrogate interface, encapsulating a Guacamole | ||
* filesystem object while it is active, allowing it to be detached and | ||
* reattached from different client views. | ||
* | ||
* | ||
* @constructor | ||
* @param {ManagedFilesystem|Object} [template={}] | ||
* The object whose properties should be copied within the new | ||
|
@@ -147,13 +147,26 @@ angular.module('client').factory('ManagedFilesystem', ['$rootScope', '$injector' | |
if (mimetypes[name] === Guacamole.Object.STREAM_INDEX_MIMETYPE) | ||
type = ManagedFilesystem.File.Type.DIRECTORY; | ||
|
||
// 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; | ||
} | ||
Comment on lines
+150
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? These values do not appear to be used anywhere. |
||
|
||
// Add file entry | ||
file.files[filename] = new ManagedFilesystem.File({ | ||
mimetype : mimetypes[name], | ||
streamName : name, | ||
type : type, | ||
parent : file, | ||
name : filename | ||
mimetype: mimetypes[name], | ||
streamName: name, | ||
type: type, | ||
parent: file, | ||
name: filename | ||
}); | ||
|
||
} | ||
|
@@ -335,6 +348,72 @@ angular.module('client').factory('ManagedFilesystem', ['$rootScope', '$injector' | |
|
||
}; | ||
|
||
/** | ||
* translate the permission number to the permission string | ||
* | ||
* @param {Number} permission | ||
*/ | ||
ManagedFilesystem.permissionTranslate = function permissionTranslate(permission) { | ||
|
||
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; | ||
Comment on lines
+358
to
+366
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
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 += '-'; | ||
} | ||
Comment on lines
+368
to
+413
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
return res; | ||
} | ||
|
||
return ManagedFilesystem; | ||
|
||
}]); |
There was a problem hiding this comment.
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.