Kaydet (Commit) 58433d7d authored tarafından Stephan Bergmann's avatar Stephan Bergmann Kaydeden (comit) Andras Timar

Related rhbz#1259746: Buffer file content read from GIO UCP

...for one, this avoids sending seek requests down the GIO/GVFS stack, which can
silently fail with corrupt data read from certain broken servers for current
versions of the GIO/GVFS stack; for another, it should considerably speed up
loading documents via the GIO UCP, as LO's document type detection is notorious
for issuing lots of seek and (small-chunk and/or re-) read operations on a file.

(This issue has become more relevant after
51e0d789 "rhbz#1134285: Access dav, davs URLs
via GVFS," where the old route via the WebDAV UCP was apparently not affected by
those broken servers, so happened to start affecting opening certain remote
files in LO via Nautilus.)

Change-Id: I91f91128b2d1a16f976eafeacf216a91747f4df1
(cherry picked from commit 93a0696e)
Reviewed-on: https://gerrit.libreoffice.org/18612Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 84926c11
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include <com/sun/star/ucb/XContentCreator.hpp> #include <com/sun/star/ucb/XContentCreator.hpp>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <comphelper/seekableinput.hxx>
#include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/exc_hlp.hxx>
#include <ucbhelper/contentidentifier.hxx> #include <ucbhelper/contentidentifier.hxx>
#include <ucbhelper/propertyvalueset.hxx> #include <ucbhelper/propertyvalueset.hxx>
...@@ -846,9 +847,9 @@ bool Content::feedSink( uno::Reference< uno::XInterface > xSink, ...@@ -846,9 +847,9 @@ bool Content::feedSink( uno::Reference< uno::XInterface > xSink,
if (!pStream) if (!pStream)
convertToException(pError, static_cast< cppu::OWeakObject * >(this)); convertToException(pError, static_cast< cppu::OWeakObject * >(this));
uno::Reference< io::XInputStream > xIn = new ::gio::InputStream(pStream); uno::Reference< io::XInputStream > xIn(
if ( !xIn.is() ) new comphelper::OSeekableInputWrapper(
return false; new ::gio::InputStream(pStream), m_xContext));
if ( xOut.is() ) if ( xOut.is() )
copyData( xIn, xOut ); copyData( xIn, xOut );
......
...@@ -29,7 +29,7 @@ using namespace com::sun::star; ...@@ -29,7 +29,7 @@ using namespace com::sun::star;
namespace gio namespace gio
{ {
InputStream::InputStream(GFileInputStream *pStream) : Seekable(G_SEEKABLE(pStream)), mpStream(pStream) InputStream::InputStream(GFileInputStream *pStream): mpStream(pStream)
{ {
if (!mpStream) if (!mpStream)
throw io::NotConnectedException(); throw io::NotConnectedException();
...@@ -57,16 +57,11 @@ void SAL_CALL InputStream::skipBytes( sal_Int32 nBytesToSkip ) ...@@ -57,16 +57,11 @@ void SAL_CALL InputStream::skipBytes( sal_Int32 nBytesToSkip )
throw( io::NotConnectedException, io::BufferSizeExceededException, throw( io::NotConnectedException, io::BufferSizeExceededException,
io::IOException, uno::RuntimeException, std::exception ) io::IOException, uno::RuntimeException, std::exception )
{ {
if (!mpStream) // Conservatively call readBytes and discard the read data, but given this
throw io::NotConnectedException(); // InputStream will always be wrapped in comphelper::OSeekableInputWrapper,
// this function will never be called anyway:
if (!g_seekable_can_seek(G_SEEKABLE(mpStream))) css::uno::Sequence<sal_Int8> data;
throw io::IOException("Seek unsupported", readBytes(data, nBytesToSkip);
static_cast< cppu::OWeakObject * >(this));
GError *pError=NULL;
if (!g_seekable_seek(G_SEEKABLE(mpStream), nBytesToSkip, G_SEEK_CUR, NULL, &pError))
convertToIOException(pError, static_cast< cppu::OWeakObject * >(this));
} }
sal_Int32 SAL_CALL InputStream::readBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) sal_Int32 SAL_CALL InputStream::readBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
...@@ -100,14 +95,6 @@ sal_Int32 SAL_CALL InputStream::readSomeBytes( uno::Sequence< sal_Int8 >& aData, ...@@ -100,14 +95,6 @@ sal_Int32 SAL_CALL InputStream::readSomeBytes( uno::Sequence< sal_Int8 >& aData,
return readBytes(aData, nMaxBytesToRead); return readBytes(aData, nMaxBytesToRead);
} }
uno::Any InputStream::queryInterface( const uno::Type &type ) throw( uno::RuntimeException, std::exception )
{
uno::Any aRet = ::cppu::queryInterface ( type,
static_cast< XInputStream * >( this ) );
return aRet.hasValue() ? aRet : Seekable::queryInterface( type );
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -22,20 +22,16 @@ ...@@ -22,20 +22,16 @@
#include <sal/types.h> #include <sal/types.h>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <cppuhelper/weak.hxx> #include <cppuhelper/implbase.hxx>
#include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XTruncate.hpp>
#include <com/sun/star/io/XSeekable.hpp>
#include "gio_seekable.hxx" #include <gio/gio.h>
namespace gio namespace gio
{ {
class InputStream : class InputStream: public cppu::WeakImplHelper<css::io::XInputStream>
public ::com::sun::star::io::XInputStream,
public Seekable
{ {
private: private:
GFileInputStream *mpStream; GFileInputStream *mpStream;
...@@ -44,12 +40,6 @@ public: ...@@ -44,12 +40,6 @@ public:
InputStream ( GFileInputStream *pStream ); InputStream ( GFileInputStream *pStream );
virtual ~InputStream(); virtual ~InputStream();
// XInterface
virtual com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type & type )
throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL acquire() throw () SAL_OVERRIDE { OWeakObject::acquire(); }
virtual void SAL_CALL release() throw() SAL_OVERRIDE { OWeakObject::release(); }
// XInputStream // XInputStream
virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 > & aData, virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 > & aData,
sal_Int32 nBytesToRead ) sal_Int32 nBytesToRead )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment