Fossil

Check-in [ee5214b7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Robustify the cleanup process.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | testerCleanup
Files: files | file ages | folders
SHA1:ee5214b7edc79518b663c0ed852b05a50c0ca544
User & Date: mistachkin 2016-03-02 06:58:21
Context
2016-03-02
07:00
Attempt to make sure that multiple calls to 'repo_init' get properly cleaned up. check-in: c464935b user: mistachkin tags: testerCleanup
06:58
Robustify the cleanup process. check-in: ee5214b7 user: mistachkin tags: testerCleanup
06:46
Fix typo. check-in: 5c674ff2 user: mistachkin tags: testerCleanup
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/tester.tcl.

   218    218     if {![file exists $::tempRepoPath]} {return}
   219    219     if {![file isdirectory $::tempRepoPath]} {return}
   220    220     set tempPathEnd [expr {[string length $::tempPath] - 1}]
   221    221     if {[string length $::tempPath] == 0 || \
   222    222         [string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} {
   223    223       error "Temporary repository path has wrong parent during cleanup."
   224    224     }
   225         -  catch {file delete -force $::tempRepoPath}
   226    225     if {[info exists ::tempSavedPwd]} {
   227    226       cd $::tempSavedPwd; unset ::tempSavedPwd
   228    227     }
          228  +  # First, attempt to forcibly delete the specific temporary repository
          229  +  # directory.
          230  +  catch {file delete -force $::tempRepoPath}
          231  +  # Next, attempt to gracefully delete the temporary repository directories.
          232  +  catch {file delete [file join $::tempPath repo_[pid] $::tempRepoSeed]}
          233  +  catch {file delete [file join $::tempPath repo_[pid]]}
          234  +  # Finally, attempt to gracefully delete the temporary home.
          235  +  if {$::tcl_platform(platform) eq "windows"} {
          236  +    catch {file delete [file join $::tempHomePath _fossil]}
          237  +  } else {
          238  +    catch {file delete [file join $::tempHomePath .fossil]}
          239  +  }
          240  +  catch {file delete $::tempHomePath}
   229    241   }
   230    242   
   231    243   proc is_home_elsewhere {} {
   232    244     return [expr {[info exists ::env(FOSSIL_HOME)] && \
   233    245         $::env(FOSSIL_HOME) eq $::tempHomePath}]
   234    246   }
   235    247   
................................................................................
   243    255   }
   244    256   
   245    257   #
   246    258   # Create and open a new Fossil repository and clean the checkout
   247    259   #
   248    260   proc repo_init {{filename ".rep.fossil"}} {
   249    261     set_home_to_elsewhere
          262  +  set ::tempRepoSeed [string trim [clock seconds] -]
   250    263     set ::tempRepoPath [file join \
   251         -      $::tempPath repo_[pid] [string trim [clock seconds] -] \
   252         -      [file tail [get_script_or_fail]]]
          264  +      $::tempPath repo_[pid] $::tempRepoSeed [file tail [get_script_or_fail]]]
   253    265     if {[catch {
   254    266       file mkdir $::tempRepoPath
   255    267     } error] != 0} {
   256    268       error "could not make directory \"$::tempRepoPath\",\
   257    269   please set TEMP variable in environment: $error"
   258    270     }
   259    271     set ::tempSavedPwd [pwd]; cd $::tempRepoPath
................................................................................
   555    567   if {$tcl_platform(platform) eq "windows"} {
   556    568     set tempPath [string map [list \\ /] $tempPath]
   557    569   }
   558    570   
   559    571   set tempPath [file normalize $tempPath]
   560    572   
   561    573   if {[catch {
   562         -  write_file [file join $tempPath temporary.txt] [clock seconds]
          574  +  set tempFile [file join $tempPath temporary.txt]
          575  +  write_file $tempFile [clock seconds]; file delete $tempFile
   563    576   } error] != 0} {
   564         -  error "could not write file to directory \"$tempPath\",\
          577  +  error "could not write file \"$tempFile\" in directory \"$tempPath\",\
   565    578   please set TEMP variable in environment: $error"
   566    579   }
   567    580   
   568    581   set tempHomePath [file join $tempPath home_[pid]]
   569    582   
   570    583   if {[catch {
   571    584     file mkdir $tempHomePath