Skip to content

Commit

Permalink
fix: removed conditional to check for jslib files (#36115)
Browse files Browse the repository at this point in the history
## Description
- Modified file writing logic for custom js lib writing logic

Fixes #32734

> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags="@tag.Git"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/10699103627>
> Commit: fe25da5
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10699103627&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Wed, 04 Sep 2024 09:58:48 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **Bug Fixes**
- Simplified the logic for saving JavaScript libraries, which may
improve performance but could affect when libraries are saved after
modifications.

- **Chores**
	- Removed unnecessary import statement, streamlining the codebase.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
sondermanish authored Sep 4, 2024
1 parent 50bbc49 commit 7d7a601
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.json.JSONObject;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.FileSystemUtils;
import org.springframework.util.StringUtils;
import reactor.core.publisher.Mono;
Expand Down Expand Up @@ -279,12 +278,16 @@ protected Set<String> updateEntitiesInRepo(ApplicationGitReference applicationGi

fileOperations.scanAndDeleteDirectoryForDeletedResources(validPages, baseRepo.resolve(PAGE_DIRECTORY));

// Save JS Libs if there's at least one change
if (modifiedResources != null
&& (modifiedResources.isAllModified()
|| !CollectionUtils.isEmpty(
modifiedResources.getModifiedResourceMap().get(CUSTOM_JS_LIB_LIST)))) {
// Earlier this condition included that modified resource not be null, and
// it should either have allModified flag turned as true or CUSTOM_JS_LIB_LIST resource map is not empty
// Save JS Libs if there's at least one change.

// What are the possible caveats of making this change?
// Since each resource in the entry needs to be present in the Modified resource map to be written
// There won't be any differences in writing files.
// In terms of performance, we would need to access the customJSLib directory every time to
// compare with the valid js libs.
if (modifiedResources != null) {
Path jsLibDirectory = baseRepo.resolve(JS_LIB_DIRECTORY);
Set<Map.Entry<String, Object>> jsLibEntries =
applicationGitReference.getJsLibraries().entrySet();
Expand Down

0 comments on commit 7d7a601

Please sign in to comment.