ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Temp files on the IFS who creates them ??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Temp files on the IFS who creates them ??

    Hi, do you have same idea on why the system could be creating a copy of a file and with the post fix TEMP[digits]. I have a process that's creates a file and then another process that deletes that same file, but I've been noticing that same files are left behind with an extra part on the name. Example the file create is FILE.

    html

    and the file left behind is FILE.htmlTEMP12345. Have been doing various test but I cannot get the same result.

  • #2
    My first thought was that it could be WrtHTMLToStmf in CGIDEV2 but it doesn't fit completely to the source I have.

    The digits could be the job number so you have to find out what this job has done.
    What program constructs a temporary file name of that format?
    Scan the sources for the string "TEMP" and ".html".
    Then check for what it does with the temporary file - rename, copy etc.
    And what happens if the "to-file" ( FILE.html ) already exists?
    Or if it has a different owner and the current user is not allowed to delete ifs files with other owners?

    Regards
    Peder

    Comment


    • fernandovch
      fernandovch commented
      Editing a comment
      Hi Peder,

      this is how I create and then erase the file.

      timestamp = %char(timestampVar);
      fullName = %trim( path ) + %trim( 'NAKACK' + timestamp +'.html');
      WrtHtmlToStmf(%trim( fullName ));

      After that I call a summit job to another program that reads the file from the IFS

      dcl-s IfsFile sqltype(clob_file) ;
      dcl-s String varchar(6000) ;

      exec sql
      SET OPTION COMMIT = *NONE, CLOSQLCSR = *ENDMOD ;

      clear IfsFile ;
      IfsFile_Name = %trimr( filePath ) ;
      IfsFile_NL = %len( filePath ) ;

      IfsFile_FO = SQFRD ; // Read only
      exec sql SET :StringOfTheFileRead = :IfsFile ;

      And Finally I erase it using

      unlink(%trim( fileNameOnTheIFS ))

  • #3
    OK so you are using WrtHTMLToStmf.
    From what you write it is clear that the renaming of the file fails in WrtHTMLToStmf.

    Is it failing all the time or just now and then? Or can you reproduce the error?
    Is it the same user or different users? Perhaps an authority failure on the IFS folder ?

    If you can reproduce it the try to enable debug before executing WrtHTMLToStmf.
    In all my code using CGIDEV2 I start with the following snippet of code:

    D wNoDebug s N inz('1')

    // wNoDebug = '0'; // NOW debug is enabled.
    wNoDebug = '1'; //
    NOW debug is not enabled.
    SetNoDebug(wNoDebug);


    If you enable it data will be logged at the physical file CGIDEBUG.

    Regards
    Peder

    Comment


    • #4
      This code is wrong:
      Code:
      clear IfsFile ;
      IfsFile_Name = %trimr( filePath ) ;
      IfsFile_NL = %len( filePath ) ;
      It makes no sense to trim the filePath when assigning to IfsFile_Name, as that is a fixed-length field, so the blanks will simply be added back on. Furthermore, you haven't removed the blanks from the %len() calculation on the line afterwards. Off the top of my head, the code should be as follows:

      Code:
      clear IfsFile ;
      IfsFile_Name =  filePath ;
      IfsFile_NL = %len( %trimr(filePath) ) ;
      It will only pay attention to the part of the IfsFile_Name that's within the length specified by IfsFile_NL. So to eliminate the trailing blanks, you trim them before calculating the length.

      Also, this is a more minor thing, but... since you're triming only trailing blanks here, you should also trim only trailing blanks when you unlink it:
      Code:
      unlink(%trimr( fileNameOnTheIFS ));
      That is only a problem if the filename contains leading blanks, so is likely something you haven't noticed, but as long as you're changing other things, changing the trim to trimr is an easy fix.

      Comment

      Working...
      X