Bug 688565 - Contents of .svn directory is enumerated as resources.
Summary: Contents of .svn directory is enumerated as resources.
Status: RESOLVED INVALID
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: General (show other bugs)
Version: master
Hardware: PC Linux
: P3 enhancement
Assignee: Alex Cherepanov
URL:
Keywords: bountiable
: 688732 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-02-24 06:22 UTC by Alex Cherepanov
Modified: 2012-02-24 23:21 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments
patch (993 bytes, patch)
2006-02-24 18:21 UTC, Alex Cherepanov
Details | Diff
Fix to filenameforall for unix - do not return directories (2.01 KB, patch)
2006-06-18 06:17 UTC, Michael (Micksa) Slade
Details | Diff
bugs686853-688565.patch (18.64 KB, patch)
2009-10-26 07:52 UTC, Boris Ananine
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Cherepanov 2006-02-24 06:22:30 UTC
The files in .svn directory are enumerated as resources by 409-01.ps .
This causes 2 problems:
- The test file reports a failure.
- The file enumeration order was different that resulted in the difference in
  stdout and raster files.

Although this is not an error in Ghostscript, ignoring .svn directory in
Ghostscript during the directory enumeration seems to be much easier than
moving it out of the way in every test script.
Comment 1 Alex Cherepanov 2006-02-24 18:21:10 UTC
Created attachment 2056 [details]
patch

Log message:

Ignore .svn directory during directory enumeration because it is created
in every directory managed by Subversion and it interferes with the resource
enumeration.

The patch is testing now.
Comment 2 Alex Cherepanov 2006-02-25 07:50:02 UTC
There's no differences in the regression testing because it does
'make install'.

When Ghostscript is run with the resources that have .svn directories
there are progressions in 215-01.ps and 409-01.ps .
Comment 3 Ralph Giles 2006-02-27 12:03:58 UTC
Two comments.

Running the file myself, the error reported is:

"409-01", "CMap", "If any instances exist, verify their entries."
Fail: (/vn/prop-base try)
Fail: (/vn/text-base try)
Fail: (/vn/format try)
Fail: (/vn/README.txt try)
Fail: (/vn/empty-file try)
Fail: (/vn/entries try)
Fail: (/vn/tmp try)
Fail: (/vn/wcprops try)
Fail: (/.svn try)
Fail: (/vn/props try)

Trying /.svn is likely to fail because this is a directory not a file, but the
others look like the path is getting mangled. Just ignoring paths starting with
.svn will shadow this bug.

Second, this is really a symptom of a bug in the unix file enumeration; it
returns directory names as if they were files. The PLRM doesn't describe the
exact behaviour, but IIRC to conform to distiller we should (a) not return
directory names, only files and (b) recurse into subdirectories. I believe the
Windows implementation of the file enumeration logic does (a) but not (b).
Comment 4 Ray Johnston 2006-03-01 09:14:42 UTC
I really DON"T like this patch approach. Instead, we need to either:

1) ignore ANY directories found (platform specific)

  -or better-

2) recurse into all directories returning only files (leaves of the tree)
   not bare directory names.

The approach (2) is already listed as a bug 688853. We may want recursion
selectable since when enumerating Resources categories, we don't want to
see any recursion.

Approach (1) will avoid problems with 409-01.ps and potential problems
with resourceforall enumeration.
Comment 5 Alex Cherepanov 2006-03-01 09:27:16 UTC
The approach 2 will cause the same errors in 409-01.ps unless
.svn is ignored.
Comment 6 Ray Johnston 2006-03-01 09:33:15 UTC
The related bug is 686853, not 688853.
Comment 7 Raph Levien 2006-03-01 10:21:38 UTC
During the support call, we decided that the best resolution is #1, to make it
not recurse into directories.

The windows version already _almost_ does this, but the test for
FILE_ATTRIBUTE_DIRECTORY is failing because it's an equality test, which gives
an undesirable answer when other flag bits (such as hidden) are set. That can be
fixed easily.

The bountiable aspect of this bug is to make gp_unifs behavior consistent with
gp_ntfs. I believe that checking stat() and skipping if the directory attribute
is set will do the trick.

At the same time, it would be great to fix bug 686853, which is related.
Comment 8 Ralph Giles 2006-06-02 08:41:00 UTC
*** Bug 688732 has been marked as a duplicate of this bug. ***
Comment 9 Ralph Giles 2006-06-02 09:06:12 UTC
raise the priority since ghostscrpt no longer runs.
Comment 10 Ralph Giles 2006-06-02 09:09:50 UTC
leo, as regards this bug, please revert the patch that triggers this in normal
runs and post a reference so it can be re-applied when the issue is fixed.
Currently those of us on unix can't use trunk.
Comment 11 leonardo 2006-06-02 23:41:29 UTC
I committed a temporary workaround with the patch 
http://ghostscript.com/pipermail/gs-cvs/2006-June/006598.html

From my old experience, the best way to resolve it is to recurse subdirectories 
in filenameforall, and skip ones which are not real files. Subdirectories apper 
when a resource hane contains '/' - suc names are widely ised in fonts, which 
may appear in Resource/Font . Note the problem doesn't appear on Windows, 
because the Windows specific module is more advanced.



Comment 12 leonardo 2006-06-02 23:47:15 UTC
I meant "resource name contains '/' - such names are widely used in fonts".
Comment 13 SaGS 2006-06-05 11:49:36 UTC
The wrong resource names mentioned in comment #3 could come from 
bug 688737 "'resourceforall' truncates names of file-based resources".
Comment 14 Michael (Micksa) Slade 2006-06-18 06:17:26 UTC
Created attachment 2283 [details]
Fix to filenameforall for unix - do not return directories

Is this what you were after?
Comment 15 Ralph Giles 2007-10-25 18:24:03 UTC
Micksa, it seems no one noticed your patch when you put it in. Are you still
interested in working on this?

I'd suggest, based on reading this again, and the related bug 686853, that the
proper fix is to:

(a) Make the current enumeration code skip directories as per your patch.
(b) Make this behaviour selectable at run time, with no recursion by default.
(c) Add a boolean to gp_enumerate_files_init to request recursion, and hook it
up the the run time switch.
(d) Ignore files and directories that begin with '.' in the unix implementation.
Comment 16 Ralph Giles 2007-10-25 18:25:50 UTC
Dropping the priority, since this is not affecting customers.
Comment 17 leonardo 2007-10-27 00:19:34 UTC
I think we need to port the functionality of gp_enumerate_files_* from 
gp_ntfs.c to other platforms.
Comment 18 Boris Ananine 2009-10-26 07:52:05 UTC
Created attachment 5544 [details]
bugs686853-688565.patch

Proposed patch.
- recursion control parameter for file enumeration functions (only relevant to
unix implementation since other platforms doesn't currently implements
recursive directory traversal anyway);
- filter out directories from enumeration list for unix, ntfs, dos platforms
(OS/2 and VMS untested yet);
- ignores any file/directory names starting with dot '.' on unix platform;
- "RECURSE" dictionary name controls recursion for "filenameforall" (-dRECURSE
enables recursion which is now disabled by default);
- "-r" command line option enables recursion (old behaviour) for mkromfs
utility.
Comment 19 Hin-Tak Leung 2010-05-04 22:28:08 UTC
Assign back to reporter for further processing/decision.