@@ -39,9 +39,9 @@ const (
39
39
//
40
40
// Note:
41
41
//
42
- // 1. AtomicWriter reserves the set of pathnames starting with `..`.
43
- // 2. AtomicWriter offers no concurrency guarantees and must be synchronized
44
- // by the caller.
42
+ // 1. AtomicWriter reserves the set of pathnames starting with `..`.
43
+ // 2. AtomicWriter offers no concurrency guarantees and must be synchronized
44
+ // by the caller.
45
45
//
46
46
// The visible files in this volume are symlinks to files in the writer's data
47
47
// directory. Actual files are stored in a hidden timestamped directory which
@@ -86,35 +86,45 @@ const (
86
86
//
87
87
// The Write algorithm is:
88
88
//
89
- // 1. The payload is validated; if the payload is invalid, the function returns
90
- // 2. The current timestamped directory is detected by reading the data directory
91
- // symlink
92
- // 3. The old version of the volume is walked to determine whether any
93
- // portion of the payload was deleted and is still present on disk.
94
- // 4. The data in the current timestamped directory is compared to the projected
95
- // data to determine if an update is required.
96
- // 5. A new timestamped dir is created
97
- // 6. The payload is written to the new timestamped directory
98
- // 7. Symlinks and directory for new user-visible files are created (if needed).
89
+ // 1. The payload is validated; if the payload is invalid, the function returns
99
90
//
100
- // For example, consider the files:
101
- // <target-dir>/podName
102
- // <target-dir>/user/labels
103
- // <target-dir>/k8s/annotations
91
+ // 2. The current timestamped directory is detected by reading the data directory
92
+ // symlink
104
93
//
105
- // The user visible files are symbolic links into the internal data directory:
106
- // <target-dir>/podName -> ..data/podName
107
- // <target-dir>/usr -> ..data/usr
108
- // <target-dir>/k8s -> ..data/k8s
94
+ // 3. The old version of the volume is walked to determine whether any
95
+ // portion of the payload was deleted and is still present on disk.
109
96
//
110
- // The data directory itself is a link to a timestamped directory with
111
- // the real data:
112
- // <target-dir>/..data -> ..2016_02_01_15_04_05.12345678/
113
- // 8. A symlink to the new timestamped directory ..data_tmp is created that will
114
- // become the new data directory
115
- // 9. The new data directory symlink is renamed to the data directory; rename is atomic
116
- // 10. Old paths are removed from the user-visible portion of the target directory
117
- // 11. The previous timestamped directory is removed, if it exists
97
+ // 4. The data in the current timestamped directory is compared to the projected
98
+ // data to determine if an update is required.
99
+ //
100
+ // 5. A new timestamped dir is created
101
+ //
102
+ // 6. The payload is written to the new timestamped directory
103
+ //
104
+ // 7. Symlinks and directory for new user-visible files are created (if needed).
105
+ //
106
+ // For example, consider the files:
107
+ // <target-dir>/podName
108
+ // <target-dir>/user/labels
109
+ // <target-dir>/k8s/annotations
110
+ //
111
+ // The user visible files are symbolic links into the internal data directory:
112
+ // <target-dir>/podName -> ..data/podName
113
+ // <target-dir>/usr -> ..data/usr
114
+ // <target-dir>/k8s -> ..data/k8s
115
+ //
116
+ // The data directory itself is a link to a timestamped directory with
117
+ // the real data:
118
+ // <target-dir>/..data -> ..2016_02_01_15_04_05.12345678/
119
+ //
120
+ // 8. A symlink to the new timestamped directory ..data_tmp is created that will
121
+ // become the new data directory
122
+ //
123
+ // 9. The new data directory symlink is renamed to the data directory; rename is atomic
124
+ //
125
+ // 10. Old paths are removed from the user-visible portion of the target directory
126
+ //
127
+ // 11. The previous timestamped directory is removed, if it exists
118
128
func (w * AtomicWriter ) Write (payload map [string ]FileProjection ) error {
119
129
// (1)
120
130
cleanPayload , err := validatePayload (payload )
0 commit comments