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

fix(project-access): check for files in srv folder treats directories as files and throws exception #2923

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

Conversation

heimwege
Copy link
Contributor

@heimwege heimwege commented Feb 14, 2025

#2922

project-access checkFilesInSrvFolder currently throws an exception in case the CAP srv folder contains subfolders because those are currently being treated like files and readFiles dumps on folders.

@kjose90 would the proposed fix work for you?

@heimwege heimwege added bug Something isn't working project-access Tickets related to @sap-ux/project-access labels Feb 14, 2025
Copy link

changeset-bot bot commented Feb 14, 2025

🦋 Changeset detected

Latest commit: d60e9df

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 40 packages
Name Type
@sap-ux/project-access Patch
@sap-ux/abap-deploy-config-sub-generator Patch
@sap-ux/abap-deploy-config-writer Patch
@sap-ux/adp-flp-config-sub-generator Patch
@sap-ux/adp-tooling Patch
@sap-ux/annotation-generator Patch
@sap-ux/app-config-writer Patch
@sap-ux/cap-config-writer Patch
@sap-ux/cards-editor-middleware Patch
@sap-ux/cf-deploy-config-sub-generator Patch
@sap-ux/cf-deploy-config-writer Patch
@sap-ux/create Patch
@sap-ux/environment-check Patch
@sap-ux/fe-fpm-writer Patch
@sap-ux/fiori-annotation-api Patch
@sap-ux/fiori-generator-shared Patch
@sap-ux/flp-config-inquirer Patch
@sap-ux/flp-config-sub-generator Patch
@sap-ux/launch-config Patch
@sap-ux/mockserver-config-writer Patch
@sap-ux/odata-service-inquirer Patch
@sap-ux/odata-service-writer Patch
@sap-ux/preview-middleware Patch
@sap-ux/project-integrity Patch
@sap-ux/telemetry Patch
@sap-ux/ui5-application-inquirer Patch
@sap-ux/ui5-library-reference-inquirer Patch
@sap-ux/ui5-library-reference-sub-generator Patch
@sap-ux/ui5-library-reference-writer Patch
@sap-ux/ui5-library-writer Patch
@sap-ux/fiori-elements-writer Patch
@sap-ux/fiori-freestyle-writer Patch
@sap-ux/fe-fpm-cli Patch
@sap-ux/abap-deploy-config-inquirer Patch
@sap-ux/deploy-config-generator-shared Patch
@sap-ux/inquirer-common Patch
@sap-ux/ui5-library-sub-generator Patch
@sap-ux/generator-simple-fe Patch
@sap-ux/cf-deploy-config-inquirer Patch
@sap-ux/ui5-library-inquirer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

if (await fileExists(srvFolderPath)) {
const fileSystemFiles = await readDirectory(srvFolderPath);
for (const file of fileSystemFiles) {
const filePath = join(srvFolderPath, file);
if (await fileExists(filePath)) {
const fileContent = await readFile(filePath);
memFs.write(filePath, fileContent);
return true;
Copy link
Contributor Author

@heimwege heimwege Feb 14, 2025

Choose a reason for hiding this comment

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

Only downside with this approach is that we would accept files that exist in the file system but have been deleted in memFS as existing files.
But as this has not been checked in the erroneous version of the code either it should not harm 🤷🏻

Copy link
Contributor

Choose a reason for hiding this comment

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

@heimwege, could we create a map from memFs.dump() before line 90 and check if the file is deleted in memFs here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. But to be honest I would prefer the findBy approach as described in the description at the very top. Is there anything that prevents us from going that direction?

…access/check-files-in-srv-folder-of-CAP-project

# Conflicts:
#	packages/project-access/src/project/cap.ts
@heimwege
Copy link
Contributor Author

@Klaus-Keller I refactored to the approach I would prefer because for me this would be more reusing what we already have instead of doing the same thing over again at a different place. Can you please check?

@kjose90 Any comment from your side?

@heimwege heimwege marked this pull request as ready for review February 19, 2025 14:14
@heimwege heimwege requested a review from a team as a code owner February 19, 2025 14:14
Copy link
Contributor

Choose a reason for hiding this comment

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

I've added types for finder2 recently with #2926 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working project-access Tickets related to @sap-ux/project-access
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants