Sha256: 320d68006309866abd9fa3631a25ab46a92d4005d646194b277c3ca9a1c4b011

Contents?: true

Size: 846 Bytes

Versions: 34

Compression:

Stored size: 846 Bytes

Contents

require 'singleton'

module Scrivito
  module Migrations
    class WorkspaceLock
      include Singleton

      def validate(workspace)
        unless exists? && workspace.revision_id == File.read(filename)
          raise ScrivitoError.new("There is a migration in progress right now. \
            Please try again after the migration working copy '#{workspace.id}' has \
            been published or removed.")
        end
      end

      def write(workspace)
        File.open(filename, 'w') do |file|
          file.write(workspace.revision_id)
        end
      end

      def remove
        if exists?
          File.delete(filename)
        end
      end

      def exists?
        File.exists?(filename)
      end

      private

      def filename
        File.join(Rails.root, 'tmp/migration_store.lock')
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
scrivito_sdk-0.41.0.rc1 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.40.0 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.40.0.rc2 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.40.0.rc1 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.30.0 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.30.0.rc1 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.18.1 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.18.0 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.17.0 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.16.0 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.15.0 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.14.0 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.13.0 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.12.0 lib/scrivito/migrations/workspace_lock.rb