code_junkie

How to ensure file integrity on file write failures

Nov 13th, 2011
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. WRITER:
  2. lock file
  3. write file
  4. release file
  5.  
  6. READER:
  7. lock file
  8. read file
  9. release file
  10.  
  11. WRITER:
  12. lock temp file
  13. write temp file
  14. lock file
  15. copy temp to file
  16. release file
  17. release temp
  18. delete temp
  19.  
  20. READER:
  21. lock file
  22. read file
  23. release file
  24.  
  25. WRITER:
  26. lock temp file
  27. write temp file
  28. lock file
  29. create copying flag
  30. copy temp to file
  31. delete copying flag
  32. release file
  33. release temp
  34. delete temp
  35.  
  36. READER:
  37. lock file
  38. if copying flag exists
  39. copy temp to file
  40. delete copying flag
  41. delete temp
  42. end
  43. read file
  44. release file
  45.  
  46. WRITER:
  47. lock file
  48. write temp file
  49. create copying flag
  50. copy temp to file
  51. delete copying flag
  52. delete temp
  53. release file
  54.  
  55. READER:
  56. lock file
  57. if copying flag exists
  58. copy temp to file
  59. delete copying flag
  60. delete temp
  61. end
  62. read file
  63. release file
  64.  
  65. WRITER:
  66. lock
  67. write temp file
  68. create copying flag
  69. copy temp to file
  70. delete copying flag
  71. delete temp
  72. release
  73.  
  74. READER:
  75. lock
  76. if copying flag exists
  77. copy temp to file
  78. delete copying flag
  79. delete temp
  80. end
  81. read file
  82. release
  83.  
  84. WRITER:
  85. lock file
  86. write file position to pos-file
  87. write file
  88. remove pos-file
  89. unlock file
  90.  
  91. WRITER:
  92. lock file
  93. write writing-in-progress-file
  94. write file
  95. remove writing-in-progress-file
  96. unlock file
Add Comment
Please, Sign In to add comment