Project

General

Profile

Bug #11156

Conversion fails if source folder is a symlink

Added by Alexandru Lungu 6 months ago. Updated 6 months ago.

Status:
Review
Priority:
Normal
Target version:
-
Start date:
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
production:
No
env_name:
topics:

History

#1 Updated by Alexandru Lungu 6 months ago

If I attempt to convert a project (e.g. Hotel), but the ./abl folder is a symlink, then the conversion fails with:

     [java] EXPRESSION EXECUTION ERROR:
     [java] ---------------------------
     [java] throwException(err)
     [java] ^  { Invalid basepath! basepath = ./abl; pkg = abl; [BLOCK id <360777252865> 0:0] }
     [java] ---------------------------
     [java] EXPRESSION EXECUTION ERROR:
     [java] ---------------------------
     [java] relpkg = execLib("rel_pkg_path")
     [java]          ^  { Expression execution error @1:1 }

I had another customer project fail exactly the same, but with different error feedback (#10981).

#3 Updated by Dănuț Filimon 6 months ago

  • Assignee set to Dănuț Filimon
  • Status changed from New to WIP

I'll pick this one up.

#4 Updated by Dănuț Filimon 6 months ago

There are no issues when the symlink points to a folder in the ~/gcd/hotel_gui directory, but the problem appears when it is part of another folder that is outside ~/gcd/hotel_gui.

This is how normalizeFilename() works right now when the symlink is ../abl:
  1. home = /home/ddf/gcd/hotel_gui and filename = abl/activate-rooms-dialog.w
  2. abnormal.getCanonicalPath() = /home/ddf/gcd/abl/activate-rooms-dialog.w
  3. new File(home).getCanonicalPath() = /home/ddf/gcd/hotel_gui
  4. absolute.startsWith(home) = false
  5. filename is returned

The issue? abnormal.getCanonicalPath() = /home/ddf/gcd/abl/activate-rooms-dialog.w follows the symlink target instead of preserving it.

My fix:
  1. home = /home/ddf/gcd/hotel_gui and filename = abl/activate-rooms-dialog.w
  2. Path homeRoot = Paths.get(home).toAbsolutePath().normalize();
  3. Path inputFilename = Path input = Paths.get(filename);
  4. normalize the inputFilename
  5. inputFilename.startsWith(homeRoot) => relativize(inputFilename) and return "." + File.separator + inputFilename
  6. return the filename if nothing happened

I ran a Hotel_GUI conversion and it worked properly, I will commit the changes soon.

#5 Updated by Dănuț Filimon 6 months ago

  • % Done changed from 0 to 100
  • Status changed from WIP to Review
  • reviewer Alexandru Lungu added

Committed 11156a/16373. When using a symlink, make sure the target is preserved instead of followed. (refs: #11156)

Alexandru, please review.

Also available in: Atom PDF