-
Notifications
You must be signed in to change notification settings - Fork 2
UFAL/Fetching preview item data only when necessary #1007
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
base: dtq-dev
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 | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,12 +22,11 @@ public class FileInfo { | |||||||||||||||||||
|
|
||||||||||||||||||||
| public Hashtable<String, FileInfo> sub = null; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public FileInfo(String name, String content, String size, boolean isDirectory, Hashtable<String, FileInfo> sub) { | ||||||||||||||||||||
| public FileInfo(String name, String content, String size, boolean isDirectory) { | ||||||||||||||||||||
| this.name = name; | ||||||||||||||||||||
| this.content = content; | ||||||||||||||||||||
| this.size = size; | ||||||||||||||||||||
| this.isDirectory = isDirectory; | ||||||||||||||||||||
| this.sub = sub; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public FileInfo(String name) { | ||||||||||||||||||||
|
|
@@ -45,4 +44,8 @@ public FileInfo(String name, String size) { | |||||||||||||||||||
| this.size = size; | ||||||||||||||||||||
| isDirectory = false; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public void setSub(Hashtable<String, FileInfo> sub) { | ||||||||||||||||||||
| this.sub = sub; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+48
to
+50
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. 🛠️ Refactor suggestion Add validation to the setter method. The setter method lacks validation and could potentially cause issues if called with invalid data. public void setSub(Hashtable<String, FileInfo> sub) {
+ if (sub != null && !isDirectory) {
+ throw new IllegalStateException("Cannot set sub for non-directory FileInfo");
+ }
this.sub = sub;
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| } | ||||||||||||||||||||
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.
Critical: Missing assignment of sub map to FileInfo object.
The
submap is created on line 203 but never assigned to the FileInfo object. This will break the hierarchical structure of file previews as the sub-directory/file relationships will be lost.public FileInfo createFileInfo(PreviewContent pc) { Hashtable<String, FileInfo> sub = createSubMap(pc.sub, this::createFileInfo); - return new FileInfo(pc.name, pc.content, pc.size, pc.isDirectory); + FileInfo fileInfo = new FileInfo(pc.name, pc.content, pc.size, pc.isDirectory); + fileInfo.setSub(sub); + return fileInfo; }📝 Committable suggestion
🤖 Prompt for AI Agents