~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/vfs.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-04-07 07:52:50 UTC
  • mfrom: (3340.1.1 208418-1.4)
  • Revision ID: pqm@pqm.ubuntu.com-20080407075250-phs53xnslo8boaeo
Return the correct knit serialisation method in _StreamAccess.
        (Andrew Bennetts, Martin Pool, Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""VFS operations for the smart server.
18
18
 
27
27
import os
28
28
 
29
29
from bzrlib import errors
30
 
from bzrlib import urlutils
31
30
from bzrlib.smart import request
32
31
 
33
32
 
52
51
 
53
52
class VfsRequest(request.SmartServerRequest):
54
53
    """Base class for VFS requests.
55
 
 
 
54
    
56
55
    VFS requests are disabled if vfs_enabled() returns False.
57
56
    """
58
57
 
60
59
        if not vfs_enabled():
61
60
            raise errors.DisabledMethod(self.__class__.__name__)
62
61
 
63
 
    def translate_client_path(self, relpath):
64
 
        # VFS requests are made with escaped paths so the escaping done in
65
 
        # SmartServerRequest.translate_client_path leads to double escaping.
66
 
        # Remove it here -- the fact that the result is still escaped means
67
 
        # that the str() will not fail on valid input.
68
 
        x = request.SmartServerRequest.translate_client_path(self, relpath)
69
 
        return str(urlutils.unescape(x))
70
 
 
71
62
 
72
63
class HasRequest(VfsRequest):
73
64
 
81
72
 
82
73
    def do(self, relpath):
83
74
        relpath = self.translate_client_path(relpath)
84
 
        backing_bytes = self._backing_transport.get_bytes(relpath)
 
75
        try:
 
76
            backing_bytes = self._backing_transport.get_bytes(relpath)
 
77
        except errors.ReadError:
 
78
            # cannot read the file
 
79
            return request.FailedSmartServerResponse(('ReadError', ))
 
80
        except errors.PermissionDenied:
 
81
            return request.FailedSmartServerResponse(('PermissionDenied',))
85
82
        return request.SuccessfulSmartServerResponse(('ok',), backing_bytes)
86
83
 
87
84
 
91
88
        relpath = self.translate_client_path(relpath)
92
89
        self._relpath = relpath
93
90
        self._mode = _deserialise_optional_mode(mode)
94
 
 
 
91
    
95
92
    def do_body(self, body_bytes):
96
93
        old_length = self._backing_transport.append_bytes(
97
94
            self._relpath, body_bytes, self._mode)