~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/vfs.py

  • Committer: Andrew Bennetts
  • Date: 2008-04-07 08:20:13 UTC
  • mfrom: (3340 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3344.
  • Revision ID: andrew.bennetts@canonical.com-20080407082013-ca1n1tqqon7ugxiy
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
class HasRequest(VfsRequest):
64
64
 
65
65
    def do(self, relpath):
 
66
        relpath = self.translate_client_path(relpath)
66
67
        r = self._backing_transport.has(relpath) and 'yes' or 'no'
67
68
        return request.SuccessfulSmartServerResponse((r,))
68
69
 
70
71
class GetRequest(VfsRequest):
71
72
 
72
73
    def do(self, relpath):
 
74
        relpath = self.translate_client_path(relpath)
73
75
        try:
74
76
            backing_bytes = self._backing_transport.get_bytes(relpath)
75
77
        except errors.ReadError:
83
85
class AppendRequest(VfsRequest):
84
86
 
85
87
    def do(self, relpath, mode):
 
88
        relpath = self.translate_client_path(relpath)
86
89
        self._relpath = relpath
87
90
        self._mode = _deserialise_optional_mode(mode)
88
91
    
95
98
class DeleteRequest(VfsRequest):
96
99
 
97
100
    def do(self, relpath):
 
101
        relpath = self.translate_client_path(relpath)
98
102
        self._backing_transport.delete(relpath)
99
103
        return request.SuccessfulSmartServerResponse(('ok', ))
100
104
 
102
106
class IterFilesRecursiveRequest(VfsRequest):
103
107
 
104
108
    def do(self, relpath):
 
109
        if not relpath.endswith('/'):
 
110
            relpath += '/'
 
111
        relpath = self.translate_client_path(relpath)
105
112
        transport = self._backing_transport.clone(relpath)
106
113
        filenames = transport.iter_files_recursive()
107
114
        return request.SuccessfulSmartServerResponse(('names',) + tuple(filenames))
110
117
class ListDirRequest(VfsRequest):
111
118
 
112
119
    def do(self, relpath):
 
120
        if not relpath.endswith('/'):
 
121
            relpath += '/'
 
122
        relpath = self.translate_client_path(relpath)
113
123
        filenames = self._backing_transport.list_dir(relpath)
114
124
        return request.SuccessfulSmartServerResponse(('names',) + tuple(filenames))
115
125
 
117
127
class MkdirRequest(VfsRequest):
118
128
 
119
129
    def do(self, relpath, mode):
 
130
        relpath = self.translate_client_path(relpath)
120
131
        self._backing_transport.mkdir(relpath,
121
132
                                      _deserialise_optional_mode(mode))
122
133
        return request.SuccessfulSmartServerResponse(('ok',))
125
136
class MoveRequest(VfsRequest):
126
137
 
127
138
    def do(self, rel_from, rel_to):
 
139
        rel_from = self.translate_client_path(rel_from)
 
140
        rel_to = self.translate_client_path(rel_to)
128
141
        self._backing_transport.move(rel_from, rel_to)
129
142
        return request.SuccessfulSmartServerResponse(('ok',))
130
143
 
132
145
class PutRequest(VfsRequest):
133
146
 
134
147
    def do(self, relpath, mode):
 
148
        relpath = self.translate_client_path(relpath)
135
149
        self._relpath = relpath
136
150
        self._mode = _deserialise_optional_mode(mode)
137
151
 
143
157
class PutNonAtomicRequest(VfsRequest):
144
158
 
145
159
    def do(self, relpath, mode, create_parent, dir_mode):
 
160
        relpath = self.translate_client_path(relpath)
146
161
        self._relpath = relpath
147
162
        self._dir_mode = _deserialise_optional_mode(dir_mode)
148
163
        self._mode = _deserialise_optional_mode(mode)
161
176
class ReadvRequest(VfsRequest):
162
177
 
163
178
    def do(self, relpath):
 
179
        relpath = self.translate_client_path(relpath)
164
180
        self._relpath = relpath
165
181
 
166
182
    def do_body(self, body_bytes):
184
200
class RenameRequest(VfsRequest):
185
201
 
186
202
    def do(self, rel_from, rel_to):
 
203
        rel_from = self.translate_client_path(rel_from)
 
204
        rel_to = self.translate_client_path(rel_to)
187
205
        self._backing_transport.rename(rel_from, rel_to)
188
206
        return request.SuccessfulSmartServerResponse(('ok', ))
189
207
 
191
209
class RmdirRequest(VfsRequest):
192
210
 
193
211
    def do(self, relpath):
 
212
        relpath = self.translate_client_path(relpath)
194
213
        self._backing_transport.rmdir(relpath)
195
214
        return request.SuccessfulSmartServerResponse(('ok', ))
196
215
 
198
217
class StatRequest(VfsRequest):
199
218
 
200
219
    def do(self, relpath):
 
220
        if not relpath.endswith('/'):
 
221
            relpath += '/'
 
222
        relpath = self.translate_client_path(relpath)
201
223
        stat = self._backing_transport.stat(relpath)
202
224
        return request.SuccessfulSmartServerResponse(
203
225
            ('stat', str(stat.st_size), oct(stat.st_mode)))